;-------------------------------------------------
;8085 DISASSEMBLER LISTING
;Label  Instruction
;-------------------------------------------------

BOOST_CUT .EQU 0A5H	; Standard ;0B2H     ; 16.5 Psi
FUEL_MULT .EQU 0FFH	; 0FFH Is normal fuel, anything below reduces fuel 


L0594:  DI		; RST 0
        DI
        DI
        DI
        JMP L0001
        NOP
        JMP ECURST	; RST 1 All L0002 reset ECU completely
        NOP
        NOP
        NOP
        NOP
        NOP
        JMP ECURST	; RST 2
        NOP
        NOP
        NOP
        NOP
        NOP
        JMP ECURST	; RST 3
        NOP
        NOP
        NOP
        NOP
        NOP
        JMP ECURST	; RST 4
        NOP
        JMP ECURST	; TRAP ISR: Rising Edge Latched and High Until Sampled
        NOP
        JMP ECURST	; RST 4
        NOP
        JMP L0003	; RST 5.5: High until sampled - Timer1 (81c55) 100Hz Clock
        NOP
        JMP ECURST	; RST 6
        NOP
        JMP ADCISR	; RST 6.5: High Until Sampled - A2D Conversion Complete
        NOP
        JMP ECURST	; RST 7
        NOP
        JMP L0005	; RST 7.5 Rising Edge Latched
        NOP

L0001:  LXI SP,8100H	; Initialise Stack Pointer
        MVI A,1FH	; Mask
        SIM		; All interrupts masked and Reset edge detecting FF
        LXI H,8000H
        XRA A		; CLR A
        MOV B,A		; CLR B
L0006:  MOV M,A		; CLR Memory
        INX H		; INC Ram Address
        DCR B
        JNZ L0006	; Loop to erase all RAM in 81c55
        IN 82H		; Read input port on 81c55
        MOV B,A		; Save this reading to B
        MVI E,03H
L0008:  LXI H,3460H	; An address in the data tables at the end of the rom
        MVI D,00H
        DAD D
        MOV A,M		; For first pass, A = 0H, 2nd pass A = 0AAH, 3rd pass A = 55H
        DCX H
        MOV C,M		; For First Pass, C = 0AAH, 2nd Pass C = 55H, 3rd pass C = 0H
        LXI H,8000H	;
L0007:  CMP M		; Pointless?
        NOP
        NOP
        NOP
        NOP
        MOV M,C		; Save 0AAH,55H,00H in all ram addresses on 81c55, 10101010b, 01010101b,00000000b
        INX H
        DCR D
        JNZ L0007
        DCR E
        JNZ L0008	; Loops 3 times to test all bits in memory or summat
        MOV A,B		; Load the B value that got saved before
        ANI 04H		; Checks if the starter motor was running before and skips the code below if it isnt
        JNZ L0009
        MVI A,80H
        STA 8058H	; X000 0000b in 8058H = starter motor running bit
L0009:  MVI A,14H
        STA 806CH	; 14h in 806Ch RAM
L0285:  MVI A,0F0H	; Restart address maybe?
        STA 806DH	; F0h in 806Dh RAM
        MVI A,01H
        STA 8040H	; 01h in 8040h RAM
        STA 8046H	; 01h in 8046h RAM
        MVI A,02H
        STA 803EH	; 02h in 803Eh RAM
        STA 8043H	; 02h in 8043h RAM
        MVI A,10H
        STA 804CH	; 10h in 804Ch RAM
        MVI A,40H	
        STA 8041H	; 40h in 8041h RAM
        STA 8044H	; 40h in 8044h RAM
        MVI A,80H	
        STA 804EH	; 80h in 804Eh RAM
        STA 804FH	; 80h in 804Fh RAM
        STA 8050H	; 80h in 8050h RAM
        STA 8050H	; 80h in 8050h RAM	-ERROR -- DONE TWICE
        STA 8056H	; 80h in 8056h RAM
        LXI H,0FFFFH
        SHLD 8017H	; 0FFFFh in 8017,8018h RAM
        SHLD 8019H	; 0FFFFh in 8019,801Ah RAM
        SHLD 801BH	; 0FFFFh in 801B,801Ch RAM
        SHLD 801DH	; 0FFFFh in 801D,801Eh RAM
        SHLD 801FH	; 0FFFFh in 801F,8020h RAM 
        MVI A,01H	
        STA 807CH	; 01h in 807Ch RAM
        MVI A,03H
        STA 8074H	; 03h in 8074h RAM
        MVI A,08H
        STA 9028H	; 8h in 9028h 4bit RAM
        LDA 3452H	; A = 0Ah
        STA 8065H	; 0Ah in 8065h RAM
        STA 809BH	; 0Ah in 809Bh RAM
        STA 8061H	; 0Ah in 8061h RAM
        STA 8068H	; 0Ah in 8068h RAM
        STA 8069H	; 0Ah in 8069h RAM
        LDA 3455H	; A = 0Ah
        STA 8060H	; 0Ah in 8060h RAM
        LDA 3456H	; A = 28h
        STA 8064H	; 28h in 8064h RAM
        LDA 3458H	; A = 50h
        STA 8059H	; 50h in 8059h RAM
        LDA 3459H	; A = 28h
        STA 805AH	; 28h in 805Ah RAM
        MVI A,96H	; A = 96h
        STA 806AH	; 96h in 806Ah RAM
        LXI H,0A0AH
        SHLD 8062H	; 0Ah in 8062,8063h RAM
        LXI H,200BH	
        SHLD 8066H	; 0Bh in 8066h, 20h in 8067h RAM
        LXI H,04C8H	
        SHLD 805EH	; C8h in 805Eh, 04h in 805Fh RAM
        LDA 325CH	; A = 04h
        STA 80A0H	; 04h in 80A0h RAM
        LDA 325EH	; A = 02h
        STA 80A1H	; 02h in 80A1h RAM
        LDA 3226H	; A = 02h
        STA 902BH	; 2h in 902bh 4bit RAM
        LDA 309EH	; A = 30h
        STA 80A7H	; 30h in 80A7h RAM
        MOV H,A		; H = 30h
        LDA 309FH	; A = 02h
        ADD H		; A + H = 32h
        STA 80A8H	; 32h in 80A8h RAM
        LDA 309DH	; A = 19h
        STA 80A9H	; 19h in 80A9h RAM	
        LDA 320FH	; A = 14h
        STA 806EH	; 14h in 806Eh RAM
        LDA 3268H	; A = 02h
        STA 807BH	; 02h in 807Bh RAM
        LDA 32ACH	; A = 05h
        STA 808DH	; 05h in 808Dh RAM
        LHLD 349FH	; H = AEh, L = 01h
        SHLD 8088H	; 01h in 8088h RAM, AEh in 8089h RAM
        LHLD 34A1H	; H = FAh, L = 00h
        SHLD 80AEH	; 00h in 80AEh RAM, FAh in 80AFh RAM
        LDA 34A5H	; A = 32h
        STA 808CH	; 32h in 808Ch RAM
        LDA 3453H	; A = 0Fh
        STA 805BH	; 0Fh in 805Bh RAM
        LDA 34A3H	; A = F0h
        STA 808EH	; F0h in 808Eh RAM
        MVI A,64H	; A = 64h
        STA 808FH	; 64h in 808Fh RAM
        MVI H,0C3H	; H = c3h, L = 00h - Accessing First Timer Chip IC18
        MVI M,30H	; IC18 Counter 0 reading/loading of LSB followed by MSB, Mode 0 interrupt on Terminal Count
        MVI M,76H	; IC18 Counter 1 reading/loading of LSB followed by MSB, Mode 3 Square wave gen
        MVI M,0B0H	; IC18 Counter 2 reading/loading of LSB followed by MSB, Mode 0 interrupt on Terminal Count	
        MVI H,0D3H	; H = D3h, L = 00h - Accessing Second Timer Chip IC17
        MVI M,30H	; IC17 Counter 0 read/load LSB only, Mode 0 interrupt on Terminal Count
        MVI M,70H	; IC17 Counter 1 reading/loading of LSB followed by MSB, Mode 0 interrupt on Terminal Count
        MVI M,0B0H	; IC17 Counter 2 reading/loading of LSB followed by MSB, Mode 0 interrupt on Terminal Count
        MVI H,0E3H	; H = E3h, L = 00h - Accessing Third Timer Chip IC16
        MVI M,30H	; IC16 Counter 0 reading/loading of LSB followed by MSB, Mode 0 interrupt on Terminal Count
        MVI M,70H	; IC16 Counter 1 reading/loading of LSB followed by MSB, Mode 0 interrupt on Terminal Count
        MVI M,0B0H	; IC16 Counter 2 reading/loading of LSB followed by MSB, Mode 0 interrupt on Terminal Count
        LXI B,0001H	; B = 00h, C = 01h
        MVI H,0C0H	; H = 0C0h, L = 00h IC18, counter 0
        MOV M,C		; LSB = 01h
        MOV M,B		; MSB = 00h 
        MVI H,0E1H	; H = 0E1h, L = 00h IC16, counter 1
        MOV M,C		; LSB = 01h
        MOV M,B		; MSB = 00h 
        MVI H,0E2H	; H = 0E2h, L = 00h IC16, counter 2
        MOV M,C		; LSB = 01h
        MOV M,B		; MSB = 00h 
        MVI H,0D0H	; H = 0D0h, L = 00h IC17, counter 0
        MOV M,C		; LSB = 01h
        MOV M,B		; MSB = 00h 
        MVI H,0D1H	; H = 0D1h, L = 00h IC17, counter 1
        MOV M,C		; LSB = 01h
        MOV M,B		; MSB = 00h 
        MVI H,0D2H	; H = 0D2h, L = 00h IC17, counter 2
        MOV M,C		; LSB = 01h
        MOV M,B		; MSB = 00h 
        MVI H,0C2H	; H = 0C2h, L = 00h IC18, counter 2
        MOV M,C		; LSB = 01h
        MOV M,B		; MSB = 00h 
        LXI B,0004H	; B = 00h, C = 04h
        MVI H,0C1H	; H = 0C1h, L = 00h IC18, counter 1	So this puts out a square wave of 1/4 the freq of the input
        MOV M,C		; LSB = 04h
        MOV M,B		; MSB = 00h 
        IN 82H		; Read in port B 
        ANI 20H		; Reading the 15km/hr Input
        JNZ L0010	; Maybe if already going 15km/hr jump to L0010
        LXI B,0005H	;
        MOV D,B		; D = 00h
        MOV E,B		; E = 00h
L0012:  LXI H,9009H
        DAD D		; HL = 9009h first time round
        MOV A,M		; Load the data from RAM, probably 00h to start with
        ANI 0FH
        LXI H,2B9FH
        ADD L
        MOV L,A
        MVI A,00H
        ADC H		; A = 2Bh
        MOV H,A
        MOV A,M		; load from 2B9Fh (00H)
        ORA A		; Or A with itself, jsut to set the PSW flags for jump.
        JZ L0011	; Jump is made.
        ADD B
        ADD E		; B = A + B + (Ex3)
        ADD E
        ADD E
        MOV B,A
L0011:  INR E
        DCR C		; Initially 5h
        JNZ L0012	; Does a whole bunch of crap to B Possibly checking if there is stuff in the RAM
        MOV A,B		;
        CPI 0CH		; Compares B to 0Ch and jumps if 0Ch <= B 
        JNC L0010
        CPI 02H		; Compares B to 2h and jumps if 02h <= B 
        JZ L0010
        ADD A		; Else A = B x 4
        ADD A
        ADD A
        ADD A
        STA 8052H	; Seems to be a RAM copy of the state of Port A
        JMP L0013
L0010:  LXI H,9000H
        MVI B,0EH
        XRA A
L0014:  MOV M,A		; Erase the first 0EH addresses in the 5114
        INX H
        DCR B
        JNZ L0014
        LXI H,9100H
        XRA A
        MOV B,A
L0015:  MOV M,A		; Erase the whole block 1
        INX H
        DCR B
        JNZ L0015
        MVI A,94H	
        STA 9180H	; Store 94 in ram, but only 4 bit so ummm, 4?
        STA 9182H	; Store same in 9182
        MVI A,09H	
        STA 9181H	; Store 9 in 9181H
        STA 9183H	; and 9183
L0013:  LXI H,900EH
        MVI B,0F2H
        XRA A
L0016:  MOV M,A		; Erase the 5114 Bank 0 RAM except for 9000-900D (rest from above)
        INX H
        DCR B
        JNZ L0016
        MVI A,02H
        STA 9015H	; Store 2h in 9015 RAM
        MVI A,0C4H
        OUT 84H		; Setting the 8155 Internal Counter Low Byte
        MVI A,49H
        OUT 85H		; Load timer with 2500d, set as square wave generator.Running off CLK/12 0.01s period
        MVI A,0CDH	; Set PA as output, PB as input, PC as output, start timer, disable interrupts
        OUT 80H		; Setting the 8155 Internal Control Register
        LDA 8052H	; Load the output mask from before, likely zero, might be stuff.
        OUT 81H
        MVI B,1EH	; B = 1Eh
        LDA 806CH	; 14h intially
        ORA A
        JNZ L0017
        MVI B,1FH
L0017:  MOV A,B		; 1Eh initially
        OUT 83H		; PC = 1E, 11110b Everything off.
        STA 8053H	; Store this in 8052 RAM
        MVI H,0F1H	; Writing to the datalogging port again
        MVI M,0CH
        MVI M,3EH
        MVI A,0D8H
        STA 8054H	; Store 0D8H in the A2D ISR status byte - This just skips all storage if an ADCISR is called
        IN 0B0H		; Read in the ADC but don't care
        MVI A,0DH	;
        SIM		; Set the interrupt mask. Enable 7.5 and 5.5 but not 6.5
        EI		; Enable interrupts
        MVI A,28H
        STA 8054H	; Store 28 in the A2D ISR status byte
        LDA 8052H	; Load Port A status
        ANI 0F0H
        ADI 07H		; Add 00000111b
        STA 8052H	; Store this back and set the output AMUX chan 3 IC1
        OUT 81H		;
        OUT 0B0H	; Triggers a Start of Conversion
        MVI L,04H	; Store 4h in L, maybe a bit mask.
        CALL ADCWAIT	; Waits for the ADC for 8055H bit 2 to complete.
        MVI A,70H
        STA 8001H	; Store 70h in RAM 8001h
        MVI L,10H
        CALL ADCWAIT	; Waits for the ADC for 8055H bit 4 to complete.
        MVI A,80H
        STA 800FH	; Store 80h in RAM 800Fh	
        MVI L,08H
        CALL ADCWAIT	; Waits for the ADC for 8055H bit 3 to complete.
        MVI A,0D0H
        STA 800AH	; Store 0D0h in RAM 800Ah
        MVI L,80H
        CALL ADCWAIT	; Waits for the ADC for 8055H bit 7 to complete.
        MVI A,0FFH
        STA 800BH	; Store 0FFh in RAM 800Bh
        MVI L,02H
        CALL ADCWAIT	; Waits for the ADC for 8055H bit 1 to complete.
        MVI A,70H
        STA 8003H	; Store 070h in RAM 8003h
        MVI L,20H
        CALL ADCWAIT	; Waits for the ADC for 8055H bit 5 to complete.
        LDA 9184H	; Loads a nibble from the 5114. Should be blank to start with? Gets set to 1 later on.
        ANI 0FH
        LXI H,9180H
        JZ L0019
        LXI H,9182H
L0019:  MOV A,M
        ANI 0FH		; 04h in A
        MOV B,A		; Now in B
        INX H		; 9181H
        MOV A,M		; 09H
        ADD A		
        ADD A
        ADD A
        ADD A		; Shift Left by 2 A = 00100100b
        ADD B		; Reconstructing an 8 bit number? 101000b or 28H
        STA 800DH	; 28H in 800DH
        MVI L,40H
        CALL ADCWAIT	; Waits for the ADC for 8055H bit 2 to complete.
        DI
        CALL L0020	; Does some stuff with memory values around 3400.
        LXI D,9004H
        LDA 9000H	; Load value from 9000H, probably 0H
        ANI 0FH
        JZ L0021
        LXI D,9008H
L0021:  MVI C,04H
L0022:  DAD H		; HL = 4 x HL (HL was set in the L0020 routine)
        DAD H
        DAD H
        DAD H
        LDAX D		; Load A from 9008H
        ANI 0FH
        ORA L
        MOV L,A
        DCX D
        DCR C		; Go through it 4 times.
        JNZ L0022
        XCHG		; HL = 9004H, DE = ?
        LHLD 3493H	; L = 0E1H, H = 05H
        MOV A,L
        SUB E
        MOV A,H
        SBB D		; 16 bit subtraction
        JC L0023
        LHLD 3491H
        MOV A,E
        SUB L
        MOV A,D
        SBB H
        XCHG
        JNC L0024
L0023:  LXI H,0400H
L0024:  SHLD 8092H
        SHLD 8049H
        CALL L0025
        EI
        MVI A,02H
        STA 9011H
        MVI A,12H
        STA 8054H
        LDA 8052H
        ANI 0F0H
        ADI 02H		; AMUX Chan 1 IC2
        STA 8052H
        OUT 81H
        OUT 0B0H
        MVI L,01H
        CALL ADCWAIT
        LXI H,8080H
        SHLD 8013H
        MVI A,01H	; Does a Short Read
L0603:  STA 9011H
        MVI A,91H	; Starting with command 91H, AMPD MAP A, MAP A, MAP B, TPS, AMPD TPS
        STA 8054H
        LDA 8052H
        ANI 0F0H
        ADI 00H		; AMUX Chan 0 IC2
        STA 8052H
        OUT 81H
        OUT 0B0H
        LXI H,6002H
L0027:  LDA 9021H
        ANA L
        JNZ L0026
        DCR H
        JNZ L0027	; Wait 60 loops for Map A Conversion
L0026:  MOV A,L
        LXI H,9021H
        CMA
        ANA M
        MOV M,A		; Clear the Map A Ack bit
        LDA 8008H	; Load Map A
        STA 9026H	; store the lower 4 bits
        RRC
        RRC
        RRC
        RRC
        STA 9027H	; Store the higher 4 bits. This is an altitude adjustment
        MVI A,0B9H	; Storing B9H to a few places
        STA 8006H
        STA 8005H
        STA 8007H
        LXI H,6001H	; Reoccurs a lot, 6 s a counter, 01 is a value
L0029:  LDA 9021H
        ANA L
        JNZ L0028
        DCR H
        JNZ L0029
L0028:  MOV A,L
        LXI H,9021H
        CMA
        ANA M		; Clears the LSB
        MOV M,A
        MVI A,73H	; Store 73
        STA 80ADH
        MVI L,01H
        CALL ADCWAIT
        MVI A,4DH
        STA 8016H
        LXI H,8080H
        SHLD 8011H
        DI
        MVI H,0E0H
        MVI M,01H
        MVI M,00H	; Writing a 0 to counter 1 on IC16
        LDA 8053H
        ORI 20H		; Set all injectors ON? Setting PC5 Probably enable I guess
        OUT 83H
        STA 8053H	; Store this value back
        OUT 40H
        OUT 60H
        MVI A,58H
        SIM		; Enables all interrupts and serial output line
        EI
        XRA A		; Clear A
        STA 9011H

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;                                  Start of the Main Program Loop                                      ;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

L0182:  DI		; Disable interrupts because we are messing with ADC	
        MVI A,28H	; Load first ADC command to start a conversion loop
        STA 8054H	; store the command
        LDA 8052H	; Load the Port A status
        ANI 0F0H	; Copy any error codes
        ADI 07H		
        STA 8052H	; AMUX chan 3 IC1
        OUT 81H		; Set the AMUX
        OUT 0B0H	; Trigger a start of conversion
        EI		; Enable the interrupts again
        LDA 8058H	; Load general purpose status Register
        RRC
        JC L0030	; Jump to 30 if bit 0 was set
        RRC
        JNC L0031	; Jump to 31 if bit 1 wasn't set this stores 50H to 8059H then goes to 30H
        LDA 806DH	; Load from 806DH, possibl error code register
        ANI 0FH		; Check to see if any of the  lower bits are set.
        JNZ L0032	; If they are it jumps to 32
        LHLD 3250H	; Load from a ROM address (L = 50H, H = 12H)
        LDA 8017H	; Load the LSB of the most recent RPM Timer count
        SUB L		; take 50H away from it
        LDA 8018H	; Load the MSB
        SBB H		; Take 12H away from it
        LDA 9010H	
        JC L0033	; Jump to 33 if 1250H was larger/smaller than the RPM Timer Count might be an 800rpm threshold
        CPI 0F5H
        JNZ L0031
        XRA A
        STA 9010H
        JMP L0031	; Jump to 31 if bit 1 wasn't set this stores 50H to 8059H then goes to 30H
L0033:  ANI 0FH
        JZ L0034	; If 9010H has nothing in it then go to 34
        CPI 05H
        JNZ L0031	; Jump to 31 if 9010H had something init that wasn't 5, this stores 50H to 8059H then goes to 30H

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; I think this section checks for a disconnected MAP Sensor hose ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

L0034:  LHLD 9026H	; Load an altitude correction reading from the 4 bit RAM
        MOV A,L		; Restoring
        ANI 0FH		; Restoring
        MOV L,A		; Restoring
        MOV A,H		; Restoring
        RLC
        RLC
        RLC
        RLC		; Restoring
        ANI 0F0H	; Restoring
        ADD L		; Restoring
        MOV B,A		; And store it in B
        ADI 02H		; Add 2H to the altitude
        LXI H,8008H
        JNC L0035	; If the addition went fine then jump to 35
        MOV A,B		; If there was carry, this means the atmospheric was very high
        SUI 02H		; Take the two back off
        JMP L0036
L0035:  CMP M		; If the current Map A reading is smaller than atmospheric + 2 then jump to L0037 This means we are in NA
        JC L0037
        SUI 04H		; Otherwise take 4H off the atmospheric reading
        JC L0038
L0036:  MOV C,A
        MOV A,M
        CMP C		; Compare the actual Atmospheric value to the latest MAP reading
        JC L0037	; Jump to L0037 if the current reading is lower than atmospheric, we are in NA
L0038:  LDA 8059H	; Load 8059H
        ORA A		
        JNZ L0030	; If this isn't zero then jump to 30
        LXI B,0105H	; Otherwise if there is something in it, then go to L0039
        CALL L0039	; Crazy quite large subroutine that does stuff to do with errors and error codes.

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; End of hose check ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

L0031:  LDA 3458H	; 50H
        STA 8059H	; If there was something in 8059H then store  back 50 to it
        JMP L0030

L0037:  XRA A		; Store 0 in 9010H if we are running in NA, this means we are fine
        STA 9010H
L0032:  LXI H,8058H
        MVI A,01H
        ORA M
        MOV M,A		; Sets bit 0 in 8058H. This is checked at the start of the main program loop
			; Seems to make sure this tube test only gets done once while cranking

L0030:  LDA 8009H
        MOV C,A
        LDA 80ADH
        MOV B,A
        LDA 806DH
        ANI 0FH
        JNZ L0040
        LDA 9010H
        ANI 0FH
        JZ L0041
        CPI 0EH
        JNZ L0042
L0041:  LDA 345AH	; load another ROM value 82H
        CMP C
        JNC L0043
        LDA 345BH	; 0E6H
        CMP C
        JNC L0044
L0043:  LDA 345CH	; 30H
        CMP B
        JNC L0045
        LDA 345DH	; 79H
        CMP B
        JC L0045
L0044:  MVI A,4BH
        CALL L0046	; 4BH x B
        MOV L,A		; Store result in HL
        MOV H,B
        MVI A,37H
        MOV B,C
        CALL L0046	; 37H x C
        SUB L
        MOV L,A
        MOV A,B
        SBB H
        SUI 0EH
        MOV H,A
        RLC
        JNC L0047
        MOV A,L
        CMA
        MOV L,A
        MOV A,H
        CMA
        MOV H,A
        INX H
L0047:  SHLD 80BFH
        XCHG
        LHLD 345EH	; L = 0H, H = 02H
        MOV A,L
        SUB E
        MOV A,H
        SBB D
        JC L0048
L0045:  XRA A
        STA 9010H
        JMP L0042
L0048:  LDA 805AH
        ORA A
        JNZ L0040
        LXI B,010EH
        CALL L0039
L0042:  LDA 3459H
        STA 805AH
L0040:  IN 82H
        MOV C,A
        ANI 10H		;Reading OutO on IC16
        RRC
        STA 9016H
        JZ L0049
        LDA 806DH
        ANI 0FH
        JNZ L0050
        LDA 9010H
        CPI 0F3H
        JZ L0051
        CPI 0F7H
        JZ L0051
        CPI 0F1H
        JZ L0051
        CPI 0F4H
        JZ L0051
        CPI 0F5H
        JZ L0051
        CPI 0FEH
        JNZ L0050
L0051:  XRA A
        STA 9010H
L0050:  LDA 3452H
        STA 8065H
        STA 8061H
        STA 809BH
        LDA 3458H
        STA 8059H
        LDA 3459H
        STA 805AH
        LDA 3453H
        STA 805BH
        LDA 34A3H
        STA 808EH
L0049:  LDA 806DH
        ANI 0FH
        JNZ L0052
        LDA 9010H
        ANI 0FH
        JZ L0053
        CPI 0CH
        JNZ L0054
L0053:  MOV A,C
        ANI 04H		; Checking the starter motor input?
        JZ L0055
        XRA A
        STA 9010H
        JMP L0054
L0055:  LDA 8064H
        ORA A
        JNZ L0052
        LXI B,010CH
        CALL L0039
L0054:  LDA 3456H
        STA 8064H
L0052:  LDA 806DH
        CPI 0F8H
        MVI B,00H
        JNZ L0056	; Skip this stuff if there wasn't an error code 8
        DI
        RIM
        ANI 07H
        ORI 1CH
        SIM
        EI
        IN 82H
        ANI 08H		; Reading the latched comparitor input from N3 TDC/CYL Sensor?
        MVI B,04H
        JZ L0056	;
        OUT 60H		; INVESTIGATE
        CALL L0005
L0056:  RIM
        XRA B
        ANI 07H
        JNZ ECURST
        LXI H,0000H
        DAD SP
        LXI D,7F00H
        DAD D
        MOV A,H
        ORA L
        JNZ ECURST
        DI
        LDA 9022H
        ANI 0FH
        JZ L0057
        STA 9010H	; Store whats in 9022H This register means an error has to be called twice to error out in 9010H if there is anything there
        XRA A
        STA 9022H
L0057:  LXI H,9009H
        MOV A,M
        INX H
        ORA M
        INX H
        ORA M
        INX H
        ORA M
        INX H
        ORA M
        ANI 0FH
        JZ L0058
        EI
        LXI B,0005H
        MOV D,B
        MOV E,B
L0060:  LXI H,9009H
        DAD D
        MOV A,M
        ANI 0FH
        LXI H,2B9FH
        ADD L
        MOV L,A
        MVI A,00H
        ADC H
        MOV H,A
        MOV A,M
        ORA A
        JZ L0059
        ADD B
        ADD E
        ADD E
        ADD E
        MOV B,A
L0059:  INR E
        DCR C
        JNZ L0060
        MOV A,B
        CPI 0CH
        JNC ECURST
        ORI 0F0H
        MOV E,A
        IN 81H
        RRC
        RRC
        RRC
        RRC
        ANI 0FH
        CMP B
        JNZ ECURST
        LDA 806DH
        MOV D,A
        ANI 0FH
        MOV A,D
        JZ L0061
L0621:  CMP E
        JNZ ECURST
        LXI H,9010H
        CMP M
        JZ L0062
        CPI 0F5H
        MVI C,0FEH
        JZ L0063
        CPI 0F8H
        MVI C,0FCH
        JZ L0063
        CPI 0F9H
        JNZ ECURST
        MVI C,0FDH
L0063:  MOV A,M
        CMP C
        JNZ ECURST
L0062:  DI
        MOV E,B
        MOV A,B
        DCR E
        MVI D,00H
        LXI H,2B92H
        DAD D
        CPI 04H
        JNZ L0064
        MOV A,M
        JMP L0065
L0064:  MOV A,M
        STA 900EH
L0065:  RLC
        JNC L0066
        MVI A,01H
        STA 900FH
        JMP L0066
L0058:  IN 81H
        ANI 0F0H
        JNZ ECURST
L0061:  MVI A,0F0H
        STA 806DH
        XRA A
        STA 900EH
        STA 900FH
L0066:  EI
        LDA 8058H
        ANI 08H
        JNZ L0067
        LDA 806EH
        ORA A
        JNZ L0068
        LXI H,8058H
        MVI A,08H
        ORA M
        MOV M,A

;;;;;;;;;;;;;;; Checks to see if the starter motor is running and if so then turns off the fuel pump

L0067:  IN 82H		
        ANI 04H		; Checking to see if the starter motor is running. Low if yes.
        JZ L0068	; Jump if the starter motor running
        LHLD 8017H
        LDA 3210H	; 24H here
        SUB L		; 24H - 17H = 0DH
        LDA 3211H	; F4 here
        SBB H		; Subtract 80 from F4 with carry. = 7EH
        JC L0069	; Won't have needed carry
        LDA 9016H
        ANI 0FH
        JZ L0068
L0069:  DI
        LXI H,8053H	; Load the Port C buffer
        MVI A,04H	; Turning off the boost control solenoid
        ORA M
        JMP L0070
L0068:  DI
        LXI H,8053H	; Load the Port C buffer
        MVI A,0FBH	; Turning on the Boost Control Solenoid
        ANA M
L0070:  MOV M,A
        OUT 83H		; Set the output
        EI
        LXI B,8058H
        IN 82H
        ANI 04H		; Checking to see if the starter motor is running. Low if yes.
        JNZ L0071	; Jump to 71 if it isn't

;; This only happens when the starter motor is running;;
        LHLD 8017H	; Most recent RPM Timer Value
        XCHG		; Exchange DE with HL
        LHLD 3250H	; Load H = 12H, L = 50H
        MOV A,E		; A = Timer Value.
        SUB L		; A = Timer - 50H
        MOV A,D		; A = Timer
        SBB H		; All this checks to see if the RPM timer is larger/smaller than 1250H 
        JC L0072		
        LDAX B		; load A from 8058, something used in RPM calc?
        ORI 02H		; Set bit 1 in it. Might be starter is fast enough to start bit or something?
        STAX B		; Store it back
        LXI B,0FE01H	; Bitmask for operation below
        JMP L0073
L0072:  LXI B,0FE04H	; Bitmask for operation below
        JMP L0073

L0071:  LDAX B		; Load A from 8058H, not sure what this is, used in RPM calc.
        ANI 7FH		; Clear bit 7 in 8058H. This is the starter motor status bit.
        STAX B		
        LXI B,0FA00H	; Bitmask for operation below
L0073:  DI
        LXI H,9013H	; Some status register?
        MOV A,M
        ANA B		; Bit Mask
        ORA C		; Set bits
        MOV M,A		; Store it back
        EI
        LXI H,8053H
        LDA 8058H
        ANI 10H		; Check if bit 4 is set in status register 8058H
        JNZ L0074	; If it is, jump to 74
        LDA 806CH	; If it isn't, load 906CH
        ORA A		; ORA with itself, Sets the flags.
        JZ L0075	; Skip to 75 if no bits set.
        LDA 9013H	; Otherwise load this register
        RRC
        JNC L0076	; Check bit 0, skip to 76 if its clear.
L0075:  LDA 8058H
        ORI 10H		; Set bit 4 in the status register
        STA 8058H
L0074:  LDA 900FH
        RRC
        JC L0076
        MVI A,01H	; Setting the PGMFI Lamp bit, unsure of sense
        DI
        ORA M		; HL still has 8053H
        JMP L0077
L0076:  MVI A,0FEH	; Clearing the PGMFI Lamp bit, unsure of sense
        DI
        ANA M
L0077:  MOV M,A
        OUT 83H		; Setting or clearing the PGMFI Lamp depending on above.

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; Verifying Coolant Temp Reading ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

        EI
        LXI D,4803H
        LXI H,2807H
        MVI B,04H
        CALL L0078	; Refresh the ADC readings for IMA and TW

        LDA 8000H	; Load the recently read Coolant Temp Value
        MOV B,A		; Store it to B
        LDA 806DH	
        CPI 0F6H	; Checking for a TW Sensor error	
        JZ L0079	; Skip to 79 if there is
        ANI 0FH
        JNZ L0080	; Skip to here if there are any error codes

;; ALL IS WELL to get to here

        LDA 9010H	
        ANI 0FH
        JZ L0081	; If 9010H is empty go to 81	
        CPI 06H
        JNZ L0080	; If 9010H has something that isn't a 6 then go to the any other error codes vector
L0081:  MOV A,B		; Load our TW value
        CPI 0FBH
        JNC L0082	; Compare it to 0FBH, if its larger then jump to 82
        XRA A		; If its smaller then 0FBH then clear 9010H
        STA 9010H
L0080:  MOV A,B		; Comes here if there are any other errors, or if its fine - Load TW again
        STA 8001H	; Store it to 8001H
        JMP L0083	; Skip to 83

L0082:  LXI H,04C8H	; Come here if TW is bigger than 0FBH
        SHLD 805EH
        LDA 8060H
        ORA A
        JNZ L0084	; If there are bits set in 8060H then skip to the end
        LXI B,0106H
        CALL L0039	; Otherwise call an error

L0083:  LXI H,04C8H
        SHLD 805EH
        LDA 3455H	; 0AH
        STA 8060H	; Stick this in 8060H
        LDA 806DH
        CPI 0F6H	; Check if there is a TW Sensor error already
        JNZ L0084	; If there isn't skip to 84

L0079:  LDA 9013H	; Comes here if there is a TW sensor error
        RAR
        JC L0085
        LXI H,04C8H
        SHLD 805EH
        MVI A,70H
        STA 8001H
        JMP L0084
L0085:  LDA 805FH
        MOV C,A
        MVI B,00H
        LXI H,344DH
        DAD B
        MOV A,M
        STA 8001H

L0084:  LDA 8001H
        LXI H,3001H	; 4EH
        MVI E,05H
L0087:  CMP M		;
        JC L0086	; Compare Coolant Tempt to the memory vals below
        INX H		; Range of values go 4E,52,9E,C9,F7
        DCR E
        JNZ L0087

L0086:  MOV B,M		; Come here when we break out of the loop. E high = low(?) coolant temp
        DCX H		; Store the value that broke us out of the loop to B, and decrement H
        MOV C,M		; Store this value to C. So our coolant value is between B and C
        LXI D,0009H
        DAD D		; Add 9 to the memory val below the one that busted us out of the loop
        MOV E,M		; Save this to E; Series goes 40,43,4D,53,6D- might be real coolant temp values
        INX H		; Read the next one, so we know we are between these two values, D and E
        MOV D,M
        CALL L0088	; Acc still has the coolant read in value in it

        STA 806FH	; Either 00 or FF
        LXI D,0006H
        DAD D		
        MOV E,M		; 40H 40H 4AH 5DH 76H 80H
        INX H
        MOV D,M
        LDA 8001H
        CALL L0088	; Acc still has the coolant read in value in it

        STA 8070H	; Store the result of the subroutine above in here
        LXI H,304BH
        LDA 804EH
        CPI 80H
        JZ L0089
        LXI H,3044H
L0089:  LDA 8001H
        CMP M
        JC L0090
        LDA 3055H
        STA 806BH

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; Verifying IMA Reading ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

L0090:  LXI D,3806H	
        LXI H,4803H
        MVI B,10H
        CALL L0078	; Refreshes the readings for IMA and Batt Voltage

        LDA 800EH	; IMA Raw Value
        MOV B,A		; Save it to B
        LDA 806DH
        CPI 0FBH	; Check for a IMA Error
        JZ L0091	; If there is go to 91
        ANI 0FH
        JNZ L0092	; Any other errors? Go to 92
        LDA 9010H
        ANI 0FH
        JZ L0093	; If nothing in 9010H skip to 93H
        CPI 0BH
        JNZ L0092	; If something in there and its not B then skip to 92
L0093:  MOV A,B		; Load the IMA Value back
        CPI 0FAH
        JNC L0094	; If its bigger than FAH jump to 94
        CPI 05H
        JC L0094	; If its smaller than 05H jump to 94 too
        XRA A
        STA 9010H	; Otherwise clear 9010H

L0092:  MOV A,B		; Load the IMA Value back
        STA 800FH	; Store  it in 800FH
        JMP L0095	; And jump to 95

L0094:  LDA 8069H	; Come here if IMA bigger than 0FAH
        ORA A		; Anything in 8069H?
        JNZ L0091	; If there is skip to IMA Error bit
        LXI B,810BH
        CALL L0039	; Otherwise call an IMA error

L0095:  LDA 3452H	; Come here if it all went well, or if we just called an error
        STA 8069H	; And stick 0A in 8069H

L0091:  LXI D,9A0AH	; Come here if there is an IMA error. Just skips to the End
        LXI H,3806H	
        MVI B,08H
        CALL L0078	; Refresh Batt Voltage and 02 Sensor Reading

        LXI D,0AA05H
        LXI H,9A0AH
        MVI B,80H
        CALL L0078	; Refresh IAT and 02 Sensor Reading

        LDA 808CH
        ORA A
        JNZ L0096	; Jumps a huge block of code if there was anything in 898CH
        LXI B,8056H
        LDAX B		; Load a status reg
        MOV E,A		; Store it in E
        RRC		;
        JC L0097	; Check the LSb, if it was 1 jump to 97 
        LDA 902CH
        ANI 03H
        JNZ L0098
        LXI H,3495H
        LDA 800BH
        CMP M
        JC L0099
        MOV A,E
        ANI 40H
        JZ L0098
        LDA 808EH
        ORA A
        JNZ L0097
L0099:  LDA 3487H
        STA 8084H
        MOV A,E
        ORI 01H
        STA 8056H
        JMP L0097
L0098:  LDA 34A3H
        STA 808EH
L0097:  LDA 9016H
        ANI 0FH
        JZ L0100
        LDA 803CH
        ORA A
        JNZ L0101
        MVI A,80H
        DI
        STAX B
        EI
        JMP L0096
L0100:  LDA 34B3H
        STA 803CH
L0101:  LDA 8057H
        RRC
        JC L0102
        LDAX B
        LHLD 34B5H
        RLC
        JC L0103
        LHLD 34BAH
L0103:  XCHG
        LHLD 8017H
        MOV A,E
        SUB L
        MOV A,D
        SBB H
        JC L0102
        LDA 902CH
        ANI 0FEH
        STA 902CH
        XRA A
        STA 902DH
        JMP L0104
L0102:  MVI A,01H
        STA 902DH
        LHLD 8088H
        MOV A,L
        ORA H
        JNZ L0104
        MVI A,80H
        DI
        STAX B
        MVI A,03H
        STA 902CH
        EI
L0104:  LDA 8057H
        ANI 10H
        JNZ L0105
        LDA 902CH
        ANI 0FDH
        STA 902CH
        XRA A
        STA 902EH
        JMP L0096
L0105:  MVI A,01H
        STA 902EH
        LHLD 80AEH
        MOV A,L
        ORA H
        JNZ L0096
        MVI A,80H
        DI
        STAX B
        MVI A,03H
        STA 902CH
        EI
L0096:  LDA 806DH
        ANI 0FH
        JNZ L0106	; If there is any errors then skip to 106
        LDA 9010H
        ANI 0FH
        JZ L0107	; Otherwise check 9010H like usual
        CPI 01H
        JNZ L0108
L0107:  LDA 8056H
        RLC
        JC L0109	
        LDA 9012H
        MOV C,A
        LHLD 8096H
        XCHG
        LHLD 8049H
        SHLD 8096H
        MOV A,L
        SUB E
        MOV L,A
        MOV A,H
        SBB D
        MOV H,A
        RAL
        MOV B,A
        MOV A,L
        ORA H
        JZ L0110
        MOV A,B
        STA 9012H
        XRA C
        RAR
        JNC L0110
L0109:  XRA A
        STA 9010H
        JMP L0108
L0110:  LDA 805BH
        ORA A
        JNZ L0106
        LXI B,8001H
        CALL L0039
L0108:  LDA 3453H
        STA 805BH
L0106:  CALL L0025
        LXI D,6808H
        LXI H,0AA05H
        MVI B,02H
        CALL L0078
        LDA 8002H
        MOV B,A
        LDA 806DH
        CPI 0FAH
        JZ L0111
        ANI 0FH
        JNZ L0112
        LDA 9010H
        ANI 0FH
        JZ L0113
        CPI 0AH
        JNZ L0112
L0113:  MOV A,B
        CPI 0FBH
        JNC L0114
        XRA A
        STA 9010H
L0112:  MOV A,B
        STA 8003H
        JMP L0115
L0114:  LDA 8068H
        ORA A
        JNZ L0116
        LXI B,810AH
        CALL L0039
L0115:  LDA 3452H
        STA 8068H
        LDA 806DH
        CPI 0FAH
        JNZ L0116
L0111:  MVI A,70H
        STA 8003H
L0116:  LDA 8003H
        LXI H,32DEH
        MVI C,05H
L0118:  CMP M
        JC L0117
        INX H
        INX H
        INX H
        DCR C
        JNZ L0118
L0117:  PUSH H
        CALL L0119
        SHLD 80B7H
        POP H
        LXI D,0015H
        DAD D
        LDA 8003H
        CALL L0119
        SHLD 80B9H
        LXI B,8058H
        LHLD 8017H
        XCHG
        LXI H,3480H
        LDAX B
        ANI 04H
        JZ L0120
        INX H
        INX H
L0120:  MOV A,E
        SUB M
        MOV A,D
        INX H
        SBB M
        JNC L0121
        LDAX B
        ANI 0FBH
        STAX B
        MVI A,40H
        JMP L0122
L0121:  LDAX B
        ORI 04H
        STAX B
        MVI A,0C0H
L0122:  SIM
        LXI D,0BA01H
        LXI H,6808H
        MVI B,20H
        CALL L0078
        LDA 806DH
        CPI 0F3H
        JZ L0123
        CPI 0F5H
        JZ L0123
        LDA 9013H
        RRC
        JC L0124
        LDA 9016H
        ANI 0FH
        JZ L0125
        LDA 800CH
        STA 800DH
        JMP L0124
L0125:  LHLD 8017H
        XCHG
        LHLD 34F2H
        MOV A,L
        SUB E
        MOV A,H
        SBB D
        JNC L0126
        LXI H,34F4H
        LDA 8016H
        CMP M
        JC L0126
        LDA 8072H
        ORA A
        JNZ L0124
        LXI H,34F5H
        LDA 8009H
        ADD M
        STA 800DH
        JMP L0124
L0126:  LDA 34F6H
        STA 8072H
        JMP L0124
L0123:  MVI A,94H
        STA 800DH
L0124:  LDA 800DH
        MOV C,A
        RRC
        RRC
        RRC
        RRC
        MOV B,A
        MVI A,01H
        STA 9184H
        LXI H,9180H
        MOV M,C
        INX H
        MOV M,B
        XRA A
        STA 9184H
        LXI H,9182H
        MOV M,C
        INX H
        MOV M,B
        LXI B,02FDH
        LDA 9013H
        RRC
        JC L0127
        LDA 80A5H
        ORA A
        JNZ L0127
        LXI H,3076H
        LDA 8053H
        ANA B
        JNZ L0128
        LXI H,307BH
L0128:  LDA 8001H
        CMP M
        INX H
        JNC L0127
        LDA 8017H
        SUB M
        INX H
        LDA 8018H
        SBB M
        INX H
        JC L0129
        LDA 8003H
        CMP M
        JC L0127
L0129:  INX H
        LDA 800DH
        CMP M
        JC L0127
        LHLD 807DH
        MOV A,L
        ORA H
        JNZ L0127
        LDA 8057H
        ANI 10H
        JZ L0130
        LHLD 3084H
        XCHG
        LHLD 3080H
        DI
        LDA 8017H
        SUB L
        LDA 8018H
        SBB H
        JC L0131
        LHLD 801FH
        LDA 8017H
        SUB L
        MOV L,A
        LDA 8018H
        SBB H
        MOV H,A
        JC L0131
        MOV A,L
        SUB E
        MOV A,H
        SBB D
        JC L0131
        LDA 3088H
        STA 80A6H
L0131:  EI
        LDA 80A6H
        ORA A
        JNZ L0127
L0130:  DI
        LDA 8053H
        ORA B
        STA 8053H
        JMP L0132
L0127:  DI
        LDA 8053H
        ANA C
        STA 8053H
L0132:  OUT 83H
        EI
        LXI D,0000H
        LXI H,0BA01H
        MVI B,40H
        CALL L0078
        CALL L0020
        MVI C,08H
        LHLD 8017H
        XCHG
        LXI H,316BH
L0134:  MOV A,E
        SUB M
        MOV B,A
        INX H
        MOV A,D
        SBB M
        JC L0133
        MOV D,A
        MOV E,B
        INX H
        DCR C
        JNZ L0134
        XRA A
        STA 8039H
        LHLD 3179H
        XCHG
        JMP L0135
L0133:  MOV A,C
        DCR A
        STA 8039H
L0135:  MVI A,08H
        SUB C
        MOV C,A
        JZ L0136
        MOV A,D
        RAR
        MOV D,A
        MOV A,E
        RAR
        MOV E,A
        MOV A,D
        RAR
        MOV A,E
        RAR
L0136:  STA 803BH
        LXI H,317BH
        MVI B,00H
        DAD B
        MOV A,M
        STA 803AH
        LXI H,30A0H
        MVI E,08H
        LDA 80B3H
L0138:  CMP M
        JC L0137
        INX H
        DCR E
        JNZ L0138
        DCX H
        MOV A,M
        INR E
L0137:  MOV B,A
        MVI A,08H
        CMP E
        MOV A,B
        JNZ L0139
        MOV A,M
        DCR E
        INX H
L0139:  STA 80B0H
        MOV B,M
        DCX H
        MOV C,M
        MVI D,00H
        LXI H,30A8H
        DAD D
        XCHG
        LDA 8039H
        CPI 07H
        JC L0140
        DCR A
L0140:  MOV L,A
        MVI H,00H
        DAD H
        DAD H
        DAD H
        DAD D
        MOV E,M
        DCX H
        MOV D,M
        LDA 80B0H
        CALL L0088
        STA 80B1H
        LXI D,0008H
        DAD D
        MOV D,M
        INX H
        MOV E,M
        LDA 80B0H
        CALL L0088
        STA 80B0H
        LHLD 803AH
        XCHG
L0642:  MOV B,A
        LDA 80B1H
        SUB B
        MOV C,A
        MOV A,B
        PUSH PSW
        MOV A,C
        JNC L0141
        CMA
        INR A
L0141:  MOV L,A
        MVI H,00H
        DAD H
        DAD H
        DAD H
        DAD H
        DAD H
        MOV A,D
        CALL L0142
        MOV A,E
        CALL L0142
        POP PSW
        JC L0143
        ADD L
        JMP L0144
L0143:  SUB L
L0144:  STA 80B1H
        LXI H,3129H
        LDA 8001H
        MVI E,04H
L0146:  CMP M
        JC L0145
        INX H
        DCR E
        JNZ L0146
L0145:  MOV B,M
        DCX H
        MOV C,M
        LXI D,0006H
        DAD D
        MOV E,M
        INX H
        MOV D,M
        CALL L0088
        MOV B,A
        LDA 80B1H
        SUB B
        STA 80B2H
        LDA 9030H
        RRC
        LHLD 315DH
        JC L0147
        LHLD 315FH
L0147:  XCHG
        LHLD 8017H
        MOV A,L
        SUB E
        MOV A,H
        SBB D
        RAL
        STA 9030H
        RRC
        LHLD 30E8H
        JNC L0148
        LHLD 30EAH
L0148:  SHLD 80BBH
        LDA 900EH
        ANI 0FH
        JNZ L0149
        LDA 901CH
        RRC
        LXI H,314AH
        JNC L0150
        INX H
L0150:  LDA 8001H
        CMP M
        CMC
        RAL
        STA 901CH
        RRC
        JC L0151
        LHLD 8017H
        XCHG
        LDA 9038H
        RRC
        LHLD 314CH
        JC L0152
        LHLD 314EH
L0152:  MOV A,E
        SUB L
        MOV A,D
        SBB H
        RAL
        STA 9038H
        RRC
        JNC L0153
        LDA 8071H
        LXI H,3150H
        CMP M
        JC L0154
        INX H
        CMP M
        JC L0155
L0153:  XRA A
        STA 8085H
        JMP L0149
L0155:  LDA 8085H
        ORA A
        JZ L0149
        LDA 80A7H
        LXI H,3158H
        ADD M
        MOV B,A
        LDA 8013H
        CMP B
        JC L0151
L0149:  DI
        LDA 8053H
        ORI 08H
        JMP L0156
L0154:  LDA 3152H
        STA 8085H
L0151:  DI
        LDA 8053H
        ANI 0F7H
L0156:  STA 8053H
        OUT 83H
        EI
        LDA 9018H
        ANI 0FH
        JNZ L0157
        LDA 3444H
        STA 9018H
        MVI C,00H
L0160:  LXI H,3445H
        MOV A,C
        ADD A
        ADD L
        MOV L,A
        MVI A,00H
        ADC H
        MOV H,A
        MOV E,M
        MVI D,80H
        INX H
        MOV B,M
        XCHG
        MOV A,B
        ORA A
        MOV A,M
        JZ L0158
        MOV E,M
        INX H
        MOV D,M
        XCHG
        MVI A,0FFH
L0159:  DAD H
        JC L0158
        DCR B
        JNZ L0159
        MOV A,H
L0158:  LXI H,80C1H
        MVI B,00H
        DAD B
        MOV M,A
        INR C
        MOV A,C
        CPI 04H
        JNZ L0160
        LHLD 8049H
        ORA A
        MOV A,H
        RAR
        MOV H,A
        MOV A,L
        RAR
        MOV L,A
        MOV A,H
        ORA A
        JZ L0161
        CPI 03H
        JNC L0162
        DCR A
        RAR
        MOV A,L
        RAR
        JMP L0161
L0162:  MVI A,0FFH
L0161:  STA 80C5H
        LHLD 804BH
        MOV A,L
        RAL
        MOV A,H
        RAL
        JNC L0163
        MVI A,0FFH
L0163:  STA 80C6H
        LHLD 803DH
        MVI C,03H
L0164:  ORA A
        MOV A,H
        RAR
        MOV H,A
        MOV A,L
        RAR
        MOV L,A
        DCR C
        JNZ L0164
        MOV A,H
        ORA A
        MOV A,L
        JZ L0165
        MVI A,0FFH
L0165:  STA 80C7H

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; Begin Datalogging Routines ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

        MVI D,0F1H	;Datalogging
        MVI B,0F0H
        MVI A,44H
        STAX D
        LDAX B		; Loading a command
        MOV C,A		; Saving the command
        MVI A,50H	; Loading an ack?
        STAX D
        MVI A,90H	; Loading another ack?
        STAX D
        MOV A,C
        RRC
        JC L0166
        RRC
        JC L0167
        RRC
        JC L0168
        RRC
        JC L0169
        RRC
        JC L0170
        RRC
        JC L0171
        JMP L0172
L0166:  LDA 8099H	; Sending various RAM data via the datalogging connector
        STAX B
        LDA 80ADH
        STAX B
        LDA 8001H
        STAX B
        LDA 8003H
        STAX B
        LDA 8009H
        STAX B
        LDA 8006H
        STAX B
        LDA 8017H
        STAX B
        LDA 8018H
        STAX B
        LDA 8025H
        STAX B
        LDA 8026H
        STAX B
        LDA 8027H
        STAX B
        LDA 8028H
        STAX B
        LDA 80C1H
        STAX B
        LDA 80C2H
        STAX B
        LDA 80C3H
        STAX B
        LDA 80C4H
        STAX B
        JMP L0173
L0167:  LDA 80C5H	; Sending various RAM data via the datalogging connector
        STAX B
        LDA 8013H
        STAX B
        LDA 8001H
        STAX B
        LDA 8003H
        STAX B
        LDA 80C7H
        STAX B
        LDA 8006H
        STAX B
        LDA 8017H
        STAX B
        LDA 8018H
        STAX B
        LDA 8021H
        STAX B
        LDA 8022H
        STAX B
        LDA 8023H
        STAX B
        LDA 8024H
        STAX B
        LDA 8015H
        STAX B
        LDA 8006H
        STAX B
        LDA 8041H
        STAX B
        LDA 80C5H
        STAX B
        JMP L0173
L0168:  LDA 80C5H	; Sending various RAM data via the datalogging connector
        STAX B
        LDA 8015H
        STAX B
        LDA 8001H
        STAX B
        LDA 8003H
        STAX B
        LDA 8009H
        STAX B
        LDA 8006H
        STAX B
        LDA 8017H
        STAX B
        LDA 8018H
        STAX B
        LDA 8021H
        STAX B
        LDA 8022H
        STAX B
        LDA 803DH
        STAX B
        LDA 803EH
        STAX B
        LDA 8015H
        STAX B
        LDA 8006H
        STAX B
        LDA 80C7H
        STAX B
        LDA 80C5H
        STAX B
        JMP L0173
L0169:  LDA 8041H	; Sending various RAM data via the datalogging connector
        STAX B
        LDA 8015H
        STAX B
        LDA 8001H
        STAX B
        LDA 8003H
        STAX B
        LDA 80C6H
        STAX B
        LDA 8006H
        STAX B
        LDA 8050H
        STAX B
        LDA 800AH
        STAX B
        LDA 8021H
        STAX B
        LDA 8022H
        STAX B
        LDA 803DH
        STAX B
        LDA 803EH
        STAX B
        LDA 80C6H
        STAX B
        LDA 8041H
        STAX B
        LDA 80C7H
        STAX B
        LDA 800AH
        STAX B
        JMP L0173
L0173:  LDAX B		; Where the fixed datalogging transmissions come when they are done
        MOV L,A		; Store the byte sent from the datalogging connector in L (809CH)
        LDAX B
        MOV E,A
        ANI 0FH
        MOV H,A
        ANI 08H		; Check to see if bit 3 was set, if it was store H and L immediately
        JZ L0174
        MOV A,H
        ADI 0F0H	; If the bit wasn't set then add 0F0H then store it
        MOV H,A
L0174:  SHLD 809CH	; Possibly a main Injection Correction?
        LDAX B		; Load another byte from the datalogging port
        MOV H,A		; Save this byte in H
        MOV L,E		; Load a previous command into L
        MVI C,04H	; Stick 04H in C
L0175:  MOV A,H		; Move H into A
        RAR		; Rotate A right then store it back
        MOV H,A		
        MOV A,L		
        RAR
        MOV L,A		; Same with L, rotate it right then store it back
        DCR C		; Done 4 times so end up swapping High and Low bytes
        JNZ L0175
        MOV A,H
        ANI 0FH
        MOV H,A
        ANI 08H
        JZ L0176
        MOV A,H
        ADI 0F0H
        MOV H,A
L0176:  SHLD 809EH	; CVCC Injector Correction?
        JMP L0157
L0170:  LDAX B
        MOV E,A		; save an input to E
        LDAX B
        MOV H,A		; save an input to H
        LDAX B
        MOV L,A		; save an input to L
        MOV A,H		; Move H back into A
        ADD A
        ADD A
        ADD A
        ADD A		; C = H x 4
        MOV C,A
        MOV A,E
        ANI 0F0H
        RAR
        RAR
        RAR
        RAR		; take E that was loaded in and move the high 4 bits into the low 4 bits
        ADD C		; C = Emod + (H x 4)
        MOV C,A
        MOV A,E
        ADD A
        ADD A
        ADD A
        ADD A
        MOV E,A		; E = E x 4
        MOV A,L
        ANI 0F0H
        RAR
        RAR
        RAR
        RAR		; take L that was loaded in and move the high 4 bits into the low 4 bits
        ADD E		; E = Lmod + (E x 4)
        MOV E,A
        MOV A,L
        ADD A
        ADD A
        ADD A
        ADD A
        MOV L,A		; L = L x 4
        MOV A,H
        ANI 0F0H
        RAR
        RAR
        RAR
        RAR		; take H that was loaded in and move the high 4 bits into the low 4 bits
        ADD L
        MOV D,A		; D = Hmod + (L x 4)
        MOV L,A		; L = Hmod + (L x 4)
        MVI H,80H	; H = 80H
        MOV A,M		; A = data at 80(Hmod + (L x 4))
        STAX B		; Send data out
        INX H		; 16 bit number
        MOV A,M
        STAX B		; Send second byte out
        MOV L,E		
        MOV A,M		; 80(Lmod + (E x 4))
        STAX B
        INX H		; 16 bit number
        MOV A,M
        STAX B
        MOV L,C		; 80(C = Emod + (H x 4))
        MOV A,M
        STAX B
        INX H		; 16 bit number
        MOV A,M
        STAX B
        LDA 8017H
        STAX B
        LDA 8018H
        STAX B
        LDA 8021H
        STAX B
        LDA 8022H
        STAX B
        LDA 8023H
        STAX B
        LDA 8024H
        STAX B
        MOV L,D
        MOV A,M
        STAX B
        MOV L,E
        MOV A,M
        STAX B
        MOV L,C
        MOV A,M
        STAX B
        STAX B
        JMP L0172
L0171:  LDAX B
        MOV D,A
        MVI C,0CH
        LXI H,9100H
        CPI 01H
        JZ L0177
        LXI H,9120H
        CPI 02H
        JZ L0177
        LXI H,9140H
        CPI 03H
        JZ L0177
        LXI H,9005H
        MVI C,08H
L0178:  MOV A,M
        ANI 0FH
        MOV E,A
        INX H
        MOV A,M
        ADD A
        ADD A
        ADD A
        ADD A
        ADD E
        STAX B
        INX H
        DCR C
        JNZ L0178
        LDAX B
        MOV L,A
        LDAX B
        MOV H,A
        MVI C,04H
L0179:  ORA A
        MOV A,H
        RAR
        MOV H,A
        MOV A,L
        RAR
        MOV L,A
        DCR C
        JNZ L0179
        MOV A,H
        ADI 90H
        MOV H,A
        MVI C,04H
L0180:  MOV A,M
        STAX B
        INX H
        DCR C
        JNZ L0180
        JMP L0181
L0177:  MOV A,M
        ANI 0FH
        MOV E,A
        INX H
        MOV A,M
        ADD A
        ADD A
        ADD A
        ADD A
        ADD E
        STAX B
        INX H
        DCR C
        JNZ L0177
L0181:  MOV A,D
        STAX B
        STAX B
        STAX B
        STAX B
        JMP L0172
L0172:  LXI H,0000H	; No command was recieved so store null in the two datalogging status bytes
        SHLD 809CH
        SHLD 809EH
L0157:  MVI A,0F0H	; End datalogging transmission?
        OUT 0F1H	; Sending to the Datalogging Connector

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; End Datalogging ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

        JMP L0182	; Loop

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;                                   End of the Main Program Loop                                       ;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; Beginning of 03 ISR. Gets called 100 Times a second? ;;;;;;;;;;;;;;

L0003:  DI		; Start of ISR Section
        PUSH B
        PUSH D
        PUSH H
        PUSH PSW
        RIM
        ANI 07H
        PUSH PSW
        ORI 09H
        SIM
        MVI A,02H
        STA 9011H
        MVI A,12H
        STA 8054H
        LDA 8052H
        ANI 0F0H
        ADI 02H		; Amux chan 1, IC2
        STA 8052H
        OUT 81H
        OUT 0B0H
        LXI H,8083H
        MOV A,M
        ORA A
        JZ L0183
        DCR M
L0183:  EI
        LDA 805EH
L0615:  ORA A
        JZ L0184
        DCR A
        JMP L0185
L0184:  LDA 805FH
        ORA A
        JZ L0186
        DCR A
        STA 805FH
        MVI A,0C8H
L0185:  STA 805EH
L0186:  LXI H,8085H
        MOV A,M
        ORA A
        JZ L0187
        DCR M
L0187:  LDA 808FH
        ORA A
        JZ L0188
        DCR A
        STA 808FH
        JMP L0189
L0188:  MVI A,0C7H
        STA 808FH
        LXI H,80A5H
        MOV A,M
        ORA A
        JZ L0190
        DCR M
L0190:  LXI H,80A4H
        MOV A,M
        ORA A
        JZ L0191
        DCR M
L0191:  LXI H,806BH
        MOV A,M
        ORA A
        JZ L0192
        DCR M
L0192:  LXI H,8084H
        MOV A,M
        ORA A
        JZ L0193
        DCR M
L0193:  JMP L0194
        NOP
        NOP
        NOP
        NOP
        NOP
        NOP
        NOP
        NOP
        NOP
        NOP
        NOP
        NOP
        NOP
        NOP
        NOP
L0194:  LXI H,805BH
        MOV A,M
        ORA A
        JZ L0195
        DCR M
L0195:  JMP L0196
        NOP
        NOP
        NOP
        NOP
        NOP
        NOP
L0196:  LXI H,808EH
        MOV A,M
        ORA A
        JZ L0197
        DCR M
L0197:  DI
        LXI H,806AH
        MOV A,M
        ORA A
        JZ L0198
        DCR M
        JMP L0199
L0198:  MVI A,96H
        MOV M,A
        MVI A,0BH
        STA 8066H
        LXI H,0A0AH
        SHLD 8062H
        LDA 806DH
        ANI 0FH
        JNZ L0199
        LDA 9010H
        CPI 0F8H
        JZ L0200
        CPI 0F9H
        JNZ L0199
L0200:  XRA A
        STA 9010H
L0199:  EI
L0189:  LDA 9033H
        ANI 0FH
        JNZ L0201
        LDA 34B1H	; 08H
L0201:  DCR A
        STA 9033H
        LDA 9034H
        ANI 0FH
        JNZ L0202
        LDA 34B2H	; 0AH
L0202:  DCR A
        STA 9034H
        LHLD 8088H
        LDA 902DH
        ANI 0FH
        JNZ L0203
        LDA 9033H
        ANI 0FH
        JNZ L0204
        INX H
        XCHG
        LHLD 349FH	; L = 0AEH, H = 01H	
        MOV A,E
        SUB L
        MOV A,D
        SBB H
        JNC L0205
        XCHG
L0205:  SHLD 8088H
        JMP L0204
L0203:  LDA 9034H
        ANI 0FH
        JNZ L0204
        MOV A,L
        ORA H
        JZ L0204
        DCX H
        SHLD 8088H
L0204:  LHLD 80AEH
        LDA 902EH
        ANI 0FH
        JNZ L0206
        LDA 9033H
        ANI 0FH
        JNZ L0207
        INX H
        XCHG
        LHLD 34A1H	; L = 0FAH, H = 00H
        MOV A,E
        SUB L
        MOV A,D
        SBB H
        JNC L0208
        XCHG
L0208:  SHLD 80AEH
        JMP L0207
L0206:  LDA 9034H
        ANI 0FH
        JNZ L0207
        MOV A,L
        ORA H
        JZ L0207
        DCX H
        SHLD 80AEH
L0207:  LDA 902AH
        ANI 0FH
        JZ L0209	; If 902AH is clear then do all the decrements
        DCR A		; Else decrement it and store it back.
        STA 902AH
        JMP L0210
L0209:  MVI A,09H
        JMP L0211	; Looks like an extra bit of code was chucked in here, maybe a bug fix
			; Has 3 extra decrements like those below in it.

L0597:  LXI H,807BH	; Decrements a whole heap of values if they are greater than 0
        MOV A,M
        ORA A
        JZ L0212
        DCR M
L0212:  LXI H,808DH	; Decrements if > 0
        MOV A,M
        ORA A
        JZ L0213
        DCR M
L0213:  LXI H,8087H	; Decrements if > 0
        MOV A,M
        ORA A
        JZ L0214
        DCR M
L0214:  LXI H,8065H	; Decrements if > 0
        MOV A,M
        ORA A
        JZ L0215
        DCR M
L0215:  LXI H,8060H	; Decrements if > 0
        MOV A,M
        ORA A
        JZ L0216
        DCR M
L0216:  LXI H,8061H	; Decrements if > 0
        MOV A,M
        ORA A
        JZ L0217
        DCR M
L0217:  LXI H,8069H	; Decrements if > 0
        MOV A,M
        ORA A
        JZ L0218
        DCR M
L0218:  LXI H,8068H	; Decrements if > 0
        MOV A,M
        ORA A
        JZ L0219
        DCR M
L0219:  LXI H,806CH	; Decrements if > 0
        MOV A,M
        ORA A
        JZ L0220
        DCR M
L0220:  LXI H,806EH	; Decrements if > 0
        MOV A,M
        ORA A
        JZ L0221
        DCR M
L0221:  LXI H,808CH	; Decrements if > 0
        MOV A,M
        ORA A
        JZ L0222
        DCR M
L0222:  LXI H,80A6H	; Decrements if > 0
        MOV A,M
        ORA A
        JZ L0223
        DCR M
L0223:  LDA 9018H	; Decrements if > 0
        ANI 0FH
        JZ L0224
        DCR A
        STA 9018H
L0224:  LXI H,809BH	; Decrements if > 0
        MOV A,M
        ORA A
        JZ L0225
        DCR M
L0225:  LXI H,8072H	; Decrements if > 0
        MOV A,M
        ORA A
        JZ L0226
        DCR M
L0226:  LXI H,803CH	; Decrements if > 0
        MOV A,M
        ORA A
        JZ L0210
        DCR M

L0210:  DI
        LDA 9024H
        ANI 0FH
        JZ L0227
        DCR A
        STA 9024H
        JMP L0228

L0227:  EI
        LDA 900EH
        ANI 0FH
        JNZ L0229
        LDA 804DH
        ORA A
        JZ L0230
        DCR A
        STA 804DH
        JMP L0231

L0230:  LDA 310BH	; 32H
        DCR A
        STA 804DH
        LDA 8003H
        STA 80B3H
        MOV B,A
        LXI H,80B4H
        SUB M
        MOV C,A
        MOV A,B
        PUSH PSW
        MOV A,C
        JNC L0232
        CMA
        INR A
        LXI H,310CH	; 02H
        CMP M
        INX H
        JNC L0233
L0232:  POP PSW
        JMP L0234

L0233:  MOV C,A
        MOV A,M
        CMP C
        JNC L0235
        MOV C,M
L0235:  INX H
        MOV A,M		; SOME MULTIPLY DIVIDE STUFFS
        DI
        OUT 0A0H	; First operand
        MOV A,C
        OUT 0A2H	; Second Operand	
        MVI A,02H	; Multiply command
        OUT 0A3H
        IN 0A1H		; MSB of result
        MOV H,A
        IN 0A2H		; LSB of result
        MOV L,A
        EI

        MVI A,0F0H
        ANA H
        JNZ L0236
        DAD H
        DAD H
        DAD H
        DAD H
        POP PSW
        JC L0237
        ADD H
        JNC L0238
        MVI A,0FFH
        JMP L0238
L0236:  POP PSW
        MVI A,0FFH
        JNC L0238
        INR A
        JMP L0238
L0237:  SUB H
        JNC L0238
        XRA A
L0238:  STA 80B3H
L0234:  LDA 8003H
        STA 80B4H

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; Q6 Solenoid Timer Calculation ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

L0231:  LDA 9023H
        RRC
        LHLD 3134H	; HL = 05A2H
        LXI D,3159H
        JC L0239
        LHLD 3136H	; HL = 04E2H	
        LXI D,315BH
L0239:  XCHG
        LDA 8001H	; Load the verified TW Sensor reading
        CMP M		; Compare it to whats at 315BH or 3159H
        CMC		; Compliment the carry
        JC L0240	; If the TW reading is higher or the same as the memory reading then jump
        INX H		; 315AH or 315CH
        MOV B,M		; Save this value
        LDA 9016H	
        ANI 0FH	
        JNZ L0240	; Jump to 240 if there is anything in 9016H
        LHLD 8017H	; Otherwise load the latest RPM timer
        MOV A,E		; Take it off 05A2H or 04E2H
        SUB L
        MOV A,D
        SBB H
        JC L0241	; If there was carry it means revs were slower than this value

        LDA 8016H	; Verified RAW TPS reading
        CMP B		; Compare it to what was at 315AH or 315CH
        JNC L0242	; Jumps if TPS was bigger or the same as the memory value
        MVI A,00H	; Gets here if revs high and TPS low
        STA 902FH	; Store zero to 902FH

L0241:  XRA A		; Clear A	
        STA 9023H	; Store that in 9023H
        LDA 9039H	; Load 9039H
        LXI H,3188H
        RRC		; Check the LSb of 9039H
        JNC L0243	; Skip if it wasn't set
        LXI H,318AH
L0243:  LDA 8009H	; Load verified Map A
        CMP M		; Compare to whats at 3188H or 318AH
        JC L0244	; If its smaller then skip next couple lines
        INX H		; Increment H
        CMP M		; Compare to this value, 3189H or 318BH
        CMC		; Compliment the carry
L0244:  RAL		; Rotate Map A left
        STA 9039H	; Store this in 9039H, so this stores the carry bit in 9039H
        RRC		; Rotate it back right to restore it?
        JC L0245	; Jump if there was carry?
        LHLD 3169H	; Load some values
        SHLD 8098H	; Store them to the q6 solenoid timer
        JMP L0246	; Jump to 246
L0240:  XRA A
        STA 9023H
        JMP L0245
L0242:  LDA 902FH
        ANI 0FH
        JNZ L0247
        LHLD 8017H
        XCHG
        LXI H,3161H
        LDA 8001H
        CMP M
        JC L0248
        LHLD 3162H
        MOV A,E
        SUB L
        MOV A,D
        SBB H
        JNC L0248
        LHLD 3164H
        MOV A,E
        SUB L
        MOV A,D
        SBB H
        JC L0248
        LDA 3166H
        STA 8082H
        MVI A,01H
        STA 902FH
        JMP L0247
L0248:  XRA A
        STA 8082H
L0247:  LDA 8082H
        ORA A
        LDA 80B2H
        JZ L0249
        LXI H,3167H
        ADD M
        JNC L0250
        MVI A,0FFH
L0250:  STA 80B2H
L0249:  LDA 9023H
        RRC
        JC L0251
        MVI A,01H
        STA 9023H
        LHLD 8017H
        XCHG
        LXI H,3307H
        MVI C,03H
L0253:  MOV A,M
        SUB E
        INX H
        MOV A,M
        SBB D
        INX H
        JC L0252
        INX H
        INX H
        INX H
        INX H
        INX H
        INX H
        DCR C
        JNZ L0253
L0252:  MOV E,M
        INX H
        MOV D,M
        XCHG
        SHLD 80BDH
        XCHG
        INX H
        MOV E,M
        INX H
        MOV D,M
        XCHG
        SHLD 80A2H
        XCHG
        INX H
        MOV E,M
        INX H
        MOV D,M
        LHLD 80BBH
        MOV A,L
        SUB E
        MOV A,H
        SBB D
        JC L0254
        XCHG
L0254:  SHLD 8047H
        SHLD 808AH
L0251:  LDA 9036H
        RRC
        JC L0255
        LDA 80ADH
        LXI H,3106H
        CMP M
        JC L0256
        MVI A,01H
        STA 9036H
        JMP L0255
L0256:  LHLD 8047H
        SHLD 808AH
        SHLD 8098H	; Store a value to the q6 solenoid timer
        JMP L0246
L0255:  LDA 80B2H
        LXI H,3105H
        SUB M
        MOV B,A
        LDA 80ADH
        CMP B
        JC L0257
        LHLD 3138H
        SHLD 80A2H
        LHLD 313AH
        SHLD 80BDH
L0257:  LDA 80B2H
        LXI H,80ADH
        SUB M
        JNC L0258
        CMA
        INR A
        LHLD 80A2H
        CALL L0142
        MOV A,H
        MOV D,L
        MOV E,C
        ORA A
        JNZ L0229
        LHLD 808AH
        MOV A,L
        SUB E
        MOV L,A
        MOV A,H
        SBB D
        MOV H,A
        JC L0229
        SHLD 808AH
        JMP L0259
L0258:  LHLD 80A2H
        CALL L0142
        MOV A,H
        MOV D,L
        MOV E,C
        ORA A
        JNZ L0260
        LHLD 808AH
        DAD D
        JC L0260
        XCHG
        LHLD 80BBH
        MOV A,L
        SUB E
        MOV A,H
        SBB D
        JC L0260
        XCHG
        SHLD 808AH
L0259:  LHLD 3184H
        LDA 9032H
        ANI 0FH
        RRC
        JNC L0261
        LHLD 3186H
L0261:  XCHG

        LHLD 8017H	; Load the latest RPM timer
        MOV A,E
        SUB L
        MOV A,D
        SBB H
        RAL
        STA 9032H
        RRC
        JC L0262
        LHLD 808AH
        SHLD 8098H	; Store something in the q6 solenoid timer
        JMP L0246
L0262:  LDA 80B2H
        LXI H,80ADH
        SUB M
        JNC L0263
        CMA
        INR A
        LHLD 80BDH
        CALL L0142
        MOV A,H
        MOV D,L
        MOV E,C
        ORA A
        JNZ L0264
        LHLD 808AH
        MOV A,L
        SUB E
        MOV L,A
        MOV A,H
        SBB D
        MOV H,A
        JC L0264
        SHLD 8098H	; Store something to the q6 solenoid timer
        JMP L0246
L0263:  LHLD 80BDH
        CALL L0142
        MOV A,H
        MOV D,L
        MOV E,C
        ORA A
        JNZ L0265
        LHLD 808AH
        DAD D
        JC L0265
        XCHG
        LHLD 80BBH
        MOV A,L
        SUB E
        MOV A,H
        SBB D
        JC L0265
        XCHG
        SHLD 8098H	; Store some value to this solenoid timer
        JMP L0246
L0245:  XRA A
        STA 9036H
        LXI H,0000H
        SHLD 8047H
L0229:  LXI H,0000H
        SHLD 808AH
L0264:  LXI H,0000H
        SHLD 8098H	; Store zero to the q6 solenoid timer
        JMP L0246
L0260:  LHLD 80BBH
        SHLD 808AH
L0265:  LHLD 80BBH
        SHLD 8098H	; Storing the q6 solenoid timer

;;;;;;;;;;;;;;;;;;;; End of the Q6 Solenoid Timer routine

L0246:  DI
        LDA 9031H
        RRC
        JNC L0266
        XRA A
        STA 9031H
        JMP L0267
L0266:  MOV A,L
        ORA H
        JZ L0267
        XCHG
        MVI H,0C2H	; Setting the C2 timer
        MOV M,E
        MOV M,D
L0267:  LDA 3148H
        DCR A
        STA 9024H
        LXI H,8082H
        MOV A,M
        ORA A
        JZ L0228
        DCR M
L0228:  OUT 40H		; What does this do I wonder? Resetting a latch I think, probably the one that calls this
        EI
        LXI D,0000H
        LXI H,1202H
        MVI B,01H
        CALL L0078	; Does an ADC reading of command 12. AMUX Chan 1 IC 2
        LDA 9019H
        ANI 0FH
        JZ L0268
        DCR A
        STA 9019H
        JMP L0269
L0268:  LDA 3212H
        DCR A
        STA 9019H
        LDA 8057H
        ANI 20H
        JNZ L0269
        LDA 8013H
        STA 8014H
        MOV B,A
        LDA 8010H
        STA 8013H
        SUB B
        JC L0270
        ADI 80H
        JNC L0271
        MVI A,0FFH
        JMP L0271
L0270:  ADI 80H
        JC L0271
        XRA A
L0271:  STA 8071H
        LXI H,3213H
        LDA 8017H
        SUB M
        LDA 8018H
        INX H
        SBB M
        JC L0272
        INX H
        LDA 8001H
        CMP M
        JC L0272
        LDA 9015H
        RRC
        JC L0272
        INX H
        LDA 8071H
        CMP M
        INX H
        JC L0273
        LDA 902BH
        ANI 0FH
        JZ L0274
        LDA 9015H
        ANI 0FDH
        STA 9015H
        INX H
        INX H
        INX H
        INX H
        LDA 8071H
        MVI C,02H
L0276:  CMP M
        JC L0275
        INX H
        INX H
        INX H
        DCR C
        JNZ L0276
L0275:  CALL L0119
        SHLD 8035H
        JMP L0277
L0273:  LDA 9015H
        ANI 02H
        JNZ L0272
        LDA 902BH
        ANI 0FH
        JZ L0274
        MOV A,M
        LXI H,8071H
        CMP M
        JNC L0274
L0277:  LDA 902BH
        ANI 0FH
        DCR A
        STA 902BH
        LHLD 8045H
        XCHG
        LHLD 803FH
        CALL L0278
        XCHG
        LHLD 8035H
        CALL L0278
        ORA A
        JNZ L0279
        XCHG
        LHLD 8037H
        DAD D
        JC L0279
        XCHG
        LHLD 302DH
        DAD D
        JNC L0280
L0279:  LXI H,0FFFFH
L0280:  DI
        SHLD 8033H
        MOV A,L
        OUT 0D2H	;IC17 Counter 2 writing INJ Enable Timer Low Byte
        MOV A,H
        OUT 0D2H	;IC17 Counter 2 writing INJ Enable Timer High Byte
        EI
        JMP L0269
L0274:  LXI H,9015H
        MVI A,01H
        ORA M
        MOV M,A
L0272:  LXI H,9015H
        MVI A,02H
        ORA M
        MOV M,A
        LXI H,8001H
        LDA 3224H
        CMP M
        LDA 3225H
        JC L0281
        LDA 3226H
L0281:  STA 902BH
L0269:  DI
        LXI H,9011H
        MVI A,0FDH
        ANA M
        MOV M,A
        POP PSW
        ORI 08H
        SIM
        POP PSW
        POP H
        POP D
        POP B
        EI
        RET		; End of the L0003 ISR



ECURST:  DI		; Start of the ECURST ISR
        LXI H,8000H
        XRA A		; A = null
        MOV B,A		; B = null
L0282:  MOV M,A		; 8000H = null
        INX H
        DCR B
        JNZ L0282	; Erase all of 8155 RAM
        LDA 8058H
        ORI 11H
        STA 8058H
        LXI H,9000H
        MVI B,00H
        XRA A
L0283:  MOV M,A
        INX H
        DCR B
        JNZ L0283	; Erase all of the 5114 RAM, 9000-90FFH
        MVI A,02H
        STA 9015H
        LXI H,9100H
        MVI B,00H
        XRA A
L0284:  MOV M,A
        INX H
        DCR B
        JNZ L0284	; Erase all of the 5114 RAM, 9100-91FFH
        MVI A,94H
        STA 9180H
        STA 9182H
        MVI A,09H
        STA 9181H
        STA 9183H
        LXI SP,8100H	; Resetting the stack pointer
        JMP L0285	; Restarting the ECU

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; Main Injector Calc and Fire Routine ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

;;;; This is possibly a bit more than just RPM, might do fuel calcs and lookups etc.

L0005:  DI		; Start of L0005 ISR, Possibly calculates revs as it is triggered by the TDC sensor
        PUSH B
        PUSH D
        PUSH H
        PUSH PSW
        RIM
        ANI 07H
        PUSH PSW
        MVI A,1FH	; Resets the TDC internal latch, turns off the serial port and masks all interrupts
        SIM
        EI
        LHLD 801DH
        SHLD 801FH
        LHLD 801BH
        SHLD 801DH
        LHLD 8019H
        SHLD 801BH
        LHLD 8017H
        SHLD 8019H	; Shift all the older RPM Timer counters back
        LDA 9015H
        ANI 0FEH
        STA 9015H	; Clear bit 0 of 9015H

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; Read the RPM Timer and reset it ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

        MVI H,0E0H
        MVI B,0FFH
        XRA A
        OUT 0E3H	; Latches the Count of Counter 0
        MOV A,M		; Reads the LSB of the latched Count Value in, 0E0XXH
        CMA		; Compliment this value
        MOV E,A		; Move This compliment into E
	STA 8017H	; Save the LSB
	MOV A,M		; Read the MSB
        CMA		; Compliment this also
        MOV D,A		; And store in D
        STA 8018H	; and 8018H
        MOV M,B		; Now Write 0FFH to the LSB and MSB of the counter 0
        MOV M,B	

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

;;; Refreshes Map A reading

        MVI A,91H	; Reads MAP A	
        STA 8054H	
        LDA 8052H
        ANI 0F0H
        ADI 00H		; AMUX 0,IC2
        STA 8052H
        OUT 81H
        OUT 0B0H	; Initiate a conversio

;;;

        LXI B,8057H	; 8057H in Bx
        LDAX B		; Load the 8057 Register
        ANI 08H		; Check bit 3
        JNZ L0286	; If the bits set, skip to 286
        LDAX B		; If the bit isn't set then set it and set the stored count values to 0FFFFH
        ORI 08H
        STAX B
        JMP L0287

L0286:  LDA 9016H	;
        ANI 0FH		; Check for bits set in 9016H
        JZ L0288	; If theres nothing skip to 288, if something then use max timer val for REV Timer
L0287:  LXI H,0FFFFH
        SHLD 8017H

L0288:  LDA 806DH	; Error Register
        CPI 0F8H	; Is there a TDC Error?
        JZ L0289	; If so then skip to 289
        ANI 0FH		
        JNZ L0290	; If there are any errors then skip to 290
        LDA 9010H
        CPI 0FCH
        JNZ L0290	; Check 9010 for a C, if it is then clear it, otherwise leave it
        XRA A
        STA 9010H
L0290:  LDA 3456H	; 28H
        STA 8064H	; 23H in 8064H
        LDA 9011H	; Load 9011H
        RRC		; Check the LSb
        LDAX B		; Load 8057H
        JNC L0291	; Jump to L0291 if bit 0 wasn't set
        ORI 02H		; Otherwise set bit 1	
        ANI 0FBH	; And clear bit 2
        STAX B
L0291:  RRC		; Check bit 0
        RRC		; Check bit 1 of 8057H
        JNC L0292	; If bit 1 was set then jump to L0292
        CALL IDVINJ	; Otherwise do an injection? There was one pending?

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; Checking the TDC sensor for errors ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;


L0292:  LDA 806DH	; Check errors
        ANI 0FH
        JNZ L0294	; If there is any skip to 294H
        LDA 9010H	; Load 9010H
        ANI 0FH
        JZ L0295	; If its clear skip to 295
        CPI 08H
        JNZ L0296	; Otherwise check if for 8, if not skip to 296, means there is some other suspicous error
L0295:  LXI D,0EDB0H
        LHLD 8017H	; Load the current RPM Timer Value
        DAD D		; Add EDB0H to it
        JC L0294	; If there is carry the engine must be going slower than 400RPM, jump to 294
        LHLD 8019H	; Loads the most current archived RPM Timer
        XCHG		; Stick it in D and move 0EDB0H into HL
        DAD D		; Add 0EDB0H to the last timer reading 
        JC L0294	; If there was a carry skip out to 294 This means the last RPM reading was slower than 400RPM
        LHLD 8017H	; Load the current RPM Timer
        MOV B,H		; Store MSB in B
        MOV C,L		; LSB in C
        DAD H		; Multiply it by two (makes it slower RPM)
        MOV A,L	
        SUB E		; Then subtract the previous RPM timer reading from it
        MOV A,H
        SBB D
        LXI H,8062H	
        JC L0297	; Carrys if revs are climbing fast, skip to 297
        XCHG		; Otherwise, swap the previous timer into HL and the 8062H into DE
        DAD H		; Multiply the previous one by two (makes it slower RPM)
        MOV A,L		
        SUB C
        MOV A,H
        SBB B		; Then take the current RPM off the previous one
        LXI H,8063H
        JNC L0294	; If it doesn't carry it means the revs ARENT dropping fast, so everything is normal?

L0297:  DCR M		; Come here if revs are climbing or dropping FAST Decrement 8062H or 8063H
        MOV A,M
        ORA A
        JNZ L0294	; If its not zero then go to the normal place
        LXI B,0108H
        CALL L0039	; Call a TDC error if we have reached the end of our fail counters
L0296:  LXI H,0A0AH	; Skip to here if there wasn't an 8 in 9010H Means a pending error of some other kind
        SHLD 8062H	; Reset the TDC Error Counters


L0294:  LDA 9013H	; Skip the error check if everything is fine or if there are other current errors
        RRC		; Check bit 0 of 9013H
        JC L0298	; If it was set, skip to L0298
        CALL CYLCHK	; Otherwise we call a CYL sensor check and injector increment
        LXI D,8057H
        LDA 9011H	; Check the LSb of 9011H
        RRC
        JC L0300	; If its set then skip all the injection stuff and bail
        LDAX D		; Load 8057H
        RRC		
        RRC	
        JC L0301	; Check bit 1 of 8057H, if its set then skip to 301

        LHLD 340FH	; HL = 01BEH
        LDA 8017H	; Load the RPM Timer
        SUB L
        LDA 8018H
        SBB H		; Take 01BEH (4204RPM) off the RPM timer
        JNC L0302	; If no carry means that Revs are slower than 4204RPM, so skip to 302
        LDAX D		; Else load 8057H
        ORI 06H		; Set bits 1 and 2
        STAX D		; Store it back
        JMP L0302	; Jump to 302

L0301:  LHLD 8017H	; Load the RPM Timer
        LDA 3411H	; Load 0D5H
        SUB L
        LDA 3412H	; Load 01H
        SBB H		; Take Current RPM Timer from 01D5H
        JNC L0303
        LDAX D
        ANI 0FDH
        STAX D
        JMP L0302
L0303:  LDAX D
        XRI 04H
        STAX D
        ANI 04H
        JNZ L0302
        JMP L0300	; does a RET, Quits the injection routine

L0289:  LHLD 8019H	; Skips to here if there is aready TDC error
        SHLD 801FH
        LDA 9013H
        RRC
        JC L0298
        JMP L0302
L0298:  DI
        LDA 9011H
        ORI 01H
        STA 9011H
        POP PSW
        PUSH PSW
        ORI 0BH
        SIM
        EI
        LHLD 8017H
        XCHG
        LHLD 324AH
        MOV A,E
        SUB L
        MOV A,D
        SBB H
        MVI A,80H
        JNC L0304
        LHLD 324CH
        MOV A,E
        SUB L
        MOV L,A
        MOV A,D
        SBB H
        MOV H,A
        LDA 324EH
        JC L0304
        LDA 324FH
        CALL L0142
        DAD H
        LDA 324EH
        ADD H
L0304:  STA 8050H
        LDA 800AH
        LXI H,301BH	; 70H
        MVI C,05H
L0306:  CMP M
        JC L0305
        INX H
        INX H
        INX H
        DCR C
        JNZ L0306
L0305:  CALL L0119
        SHLD 8037H
        LDA 8001H
        LXI H,3228H
        MVI E,05H
L0308:  CMP M
        JC L0307
        INX H
        DCR E
        JNZ L0308
L0307:  MOV D,M
        DCX H
        SUB M
        MOV C,A
        MOV A,D
        SUB M
        MOV B,A
        PUSH B
        MVI D,00H
        XCHG
        DAD H
        PUSH H
        LXI D,322EH
        DAD D
        CALL L0309
        XCHG
        SHLD 8025H
        LHLD 302DH
        DAD D
        JC L0310
        XCHG
        LHLD 802BH
        DAD D
        JNC L0311
L0310:  LXI H,0FFFFH
L0311:  SHLD 8021H
        POP H
        POP B
        LXI D,323CH
        DAD D
        CALL L0309
        SHLD 8023H
        XCHG
        SHLD 8027H
        LXI H,0000H
        SHLD 8031H
        DI
        LDA 806DH
        CPI 0F8H
        JZ L0312
        LDA 8058H
        RLC
        JC L0313	;Jump to this if the starter motor run bit was set?
        LXI H,9013H
        MOV A,M
        ANI 04H
        JNZ L0314
        MOV A,M
        ORI 04H
        MOV M,A
        OUT 60H
        MVI A,03H
        STA 8074H	; Doing a batch fire so inhibit individual firings for another 3 cycles
        XRA A
        STA 8073H
        MVI A,20H
        STA 8067H
        CALL BATINJ
        JMP L0316
L0314:  CALL CYLCHK	; Call a CYL sensor check and injector increment
        DI
        CALL IDVINJ
        JMP L0316
L0313:  MVI A,20H
        STA 8067H
        LXI H,8073H
        IN 82H
        ANI 08H		; Checking the TDC/CYL Sensor input latch has been triggered
        JZ L0317	; If it hasn't (This seems counter) go to the single injector firing routine
        OUT 60H
        MVI A,03H
        STA 8074H	; Doing a batch fire so inhibit individual firings for another 3 cycles
        MVI M,00H
        CALL BATINJ
        JMP L0316
L0317:  MOV A,M
        INR A		; Next injector in the list
        ANI 03H
        MOV M,A
        CALL IDVINJ	; Fire this injector
        JMP L0316
L0312:  LHLD 8027H
        MVI A,04H
        CALL L0142
        MOV A,H
        ORA A
        JNZ L0318
        MOV D,L
        MOV E,C
        LHLD 8037H
        DAD D
        JNC L0319
L0318:  LXI H,0FFFFH
L0319:  SHLD 8023H
        DI
        CALL BATINJ
L0316:  EI
        LXI H,32C4H
        LXI D,32C6H
        LDA 8001H
        CMP M
        JNC L0320
        INX H
        INX D
        CMP M
        JNC L0320
        INX D
L0320:  LDAX D
        MOV B,A
        LDA 8070H
        CALL L0046
        MOV H,B
        MOV L,A
        DI
        SHLD 804BH
        LXI D,0F000H
        DAD D
        JC L0321
        LXI H,1000H
        SHLD 804BH
L0321:  LDA 804CH
        LXI H,3252H
        CMP M
        JC L0322
        LHLD 804BH
        MOV A,H
        SUI 10H
        MOV H,A
        DAD H
        LDA 3253H
        CALL L0142
        MOV A,H
        ADI 10H
        MOV H,A
        JMP L0323
L0322:  LXI H,0FFFFH
L0323:  SHLD 80B5H
        EI
        LXI H,3255H
        LDA 8003H
        CMP M
        LDA 3256H
        JC L0324
        XRA A
L0324:  STA 80A4H
        LDA 3258H
        MOV B,A
        LDA 8070H
        CALL L0046
        MOV L,A
        MOV A,B
        ORA A
        RAR
        MOV H,A
        MOV A,L
        RAR
        MOV L,A
        SHLD 803FH
        LXI D,0FF00H
        DAD D
        JC L0325
        LXI H,0100H
        SHLD 803FH
L0325:  LXI H,3259H	; 2FH here
        LDA 8003H
        CMP M
        LDA 325AH	; 0FH here
        JNC L0326
        LDA 325BH	; 2D here
L0326:  STA 80A5H	
        LDA 8013H
        STA 8011H
        LDA 3452H	; 0A here
        STA 8065H
        STA 8061H
        STA 809BH
        LDA 3453H	; 0F here
        STA 805BH
        LDA 34A3H	; F0 here	
        STA 808EH
        LDA 3459H	; 2FH here
        STA 805AH
        LDA 806DH
        ANI 0FH
        JNZ L0327	; Quits the injection routine if there was any error codes
        LDA 9010H
        CPI 0F1H
        JZ L0328
        CPI 0F4H
        JZ L0328
        CPI 0F3H
        JZ L0328
        CPI 0F7H
        JZ L0328
        CPI 0FEH
        JNZ L0327	; Quits the injection routine
L0328:  XRA A
        STA 9010H
L0327:  JMP L0329	; Skips a massive block of code to just above L0300

L0302:  DI		; Skip to here if revs are lower than 4204RPM
        LDA 9011H
        ORI 01H
        STA 9011H
        POP PSW
        PUSH PSW
        ORI 09H
        SIM
        EI
        MVI C,10H
        LHLD 8017H	; Load the latest RPM timer pair into HL
        XCHG		; Shift it into D
        LXI H,3424H	; 39H
L0331:  MOV A,E		; Move the LSB into A
        SUB M		; 
        MOV B,A		; Store this in B
        INX H		; Goes 139H, 3EH, 5EH, 34H, 41H, 54H, 6FH, 9Dh, EAH, A8H, DFH, 139H, 1D4H, 14FH, 1BFH, 271H
        MOV A,D		; Get the MSB
        SBB M		; 
        JC L0330	; if there was a carry/borrow then we are done
        MOV D,A		; Store this reduced value back in D
        MOV E,B		; and the LSB in E
        INX H		; Increment H
        DCR C		; And decrement C, starts with 10H
        JNZ L0331	; Keep going around for 16 goes
        XRA A		; A = 0H
        STA 8075H	; Use 0 if its slower than 500 RPM
        LHLD 3442H	; L = 71H, H = 02H	;
        XCHG		; Stick this in DE and load the modified RPM Counter into HL
        JMP L0332	
L0330:  MOV A,C
        DCR A
        STA 8075H	; Takes 1 off how many times we had to go around, makes it range from 0 to F bigger is higher rpm
L0332:  MVI A,10H	
        SUB C		; Take how many times we had to go around away from 10H
        MOV C,A		; Save this to C
        JZ L0333	; If we skipped out first go then jump here (Means we are higher than 6000RPM)
        MOV A,D
        RAR
        MOV D,A
        MOV A,E
        RAR		; Take the reminder and div/2
        MOV E,A
        MOV A,D		
        RAR		; Rotates through carry
        MOV A,E
        RAR		; A = E /4
L0333:  STA 8077H	; If we are higher than 6000RPM this = 0, else its the MSB of what was left in RPM timer/4
        LXI H,3413H	; 00H	
        MVI B,00H
        DAD B		; C is 10H - how many times we had to go through to bust out, bigger = lower RPM
        MOV A,M		; Save this RPM dependant tabular value to 8076H
        STA 8076H	; 84H,  57H,  9EH,  7EH,  62H,  4AH,  34H,  23H,  30H,  24H,  1AH,  11H, 18H, 12H, 0DH, 0DH
			; 5990+ 5000+ 3998+ 3599+ 3200+ 2799+ 2401+ 1999+ 1600+ 1399+ 1200+ 999+ 800+ 700+ 600+ 500+
			; The plus means from that figure to the one below the next Bin up

        LXI D,3095H	; 55H
        LDA 8011H	; Not sure
        MOV B,A		; Save this to B
        LDA 804FH	; Not sure, initialized to 80H	
        CPI 80H		; Compare this to 80H
        LDA 80A7H	; Not sure what this is, initialized to 30H
        JNC L0334	; Jump if what was in 804FH was the same or greater than 80H
        INX D		; Otherwise increment D to 3096H = 59H
        LDA 80A8H	; And load 80A8H instead of 80A7H, which is initilized to 32H
L0334:  LXI H,3295H	; 02H
        ADD M		; Add 02H to whats in the Accumulator
        CMP B		; Compare this to whatever was in 8011H
        JC L0335	; If what was in 8011H is smaller than 02H + 80A7H or 80A8H then jump
        LDA 8001H
        XCHG
        CMP M
        JNC L0335
        LDA 8075H
        CPI 04H
        JNC L0336
        INR A
        MOV E,A
        LHLD 8017H
        MVI A,0A6H
        SUB L
        MVI A,0EH
        SBB H
        JNC L0337
        DCR E
L0337:  MVI D,00H
        LXI H,3097H
        DAD D
        MOV C,M
        INX H
        MOV B,M
        MOV A,B
        SUB C
        JNC L0338
        CMA
        INR A
L0338:  MOV C,A
        MOV A,B
        PUSH PSW
        LDA 8077H
        DI
        OUT 0A0H	; SOme 16 bit maths
        MOV A,C
        OUT 0A2H
        MVI A,02H
        OUT 0A3H
        IN 0A1H
        MOV H,A
        IN 0A2H
        MOV L,A
        EI
        MVI A,0F8H
        ANA H
        JNZ L0339
        DAD H
        DAD H
        DAD H
        DAD H
        DAD H
        JMP L0340
L0339:  LXI H,0FFFFH
L0340:  LDA 8076H
        CALL L0142
        POP PSW
        JNC L0341
        ADD H
        JNC L0342
        MVI A,0FFH
        JMP L0342
L0341:  SUB H
        JNC L0342
        XRA A
        JMP L0342
L0335:  MVI A,80H
        JMP L0342
L0336:  LDA 309CH
L0342:  STA 804FH
        LHLD 804BH
        XCHG
        LXI H,0EFFFH
        DAD D
        JNC L0343
        LHLD 80B5H
        MOV A,L
        SUB E
        MOV A,H
        SBB D
        LDA 80A0H
        JC L0344
        LDA 80A1H
L0344:  MOV L,A
        MOV A,E
        SUB L
        MOV E,A
        MOV A,D
        SBI 00H
        MOV D,A
        LXI H,0EFFFH
        DAD D
        JC L0345
L0343:  LXI D,1000H
        LXI H,0100H
        SHLD 803FH
L0345:  XCHG
        SHLD 804BH
        RIM
        ANI 10H
        JZ L0346
        LDA 9024H
        ANI 0FH
        JNZ L0346
        LDA 9031H
        RRC
        JC L0346
        MVI A,01H
        STA 9031H
        LHLD 8098H
        MOV A,L
        ORA H
        JZ L0346
        XCHG
        MVI H,0C2H	; IC18 Timer2, Turns on a Solenoid at Q6
        MOV M,E
        MOV M,D
L0346:  LDA 800AH
        LXI H,301BH
        MVI C,05H
L0348:  CMP M
        JC L0347
        INX H
        INX H
        INX H
        DCR C
        JNZ L0348
L0347:  CALL L0119
        SHLD 8037H
        MVI C,30H
        LXI H,9021H
L0350:  MVI A,02H
        ANA M
        JNZ L0349
        DCR C
        JNZ L0350
        MVI A,58H
        STA 8054H
        LDA 8052H
        ANI 0F0H
        ADI 0CH		; AMUX Chan 6, IC2	
        STA 8052H	; Set mask etc
        OUT 81H
        OUT 0B0H	; Initiate conversion
L0349:  DI
        MVI A,0FDH
        ANA M
        MOV M,A
        EI

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; Map Sensor A verification code ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

        LDA 8008H	; Load Map A reading
        MOV B,A
        LDA 806DH	; Load this register
        CPI 0F3H	
        JZ L0351	; Skips this if there is a Map Sensor Wiring Error Code
        CPI 0F5H
        JZ L0351	; Or a disconnected Map sensor line
        ANI 0FH
        JNZ L0352	; And goes to 352 if there are any other error codes
        LDA 9010H
        ANI 0FH
        JZ L0353	; Jumps to 353 if 9010H = F
        CPI 03H
        JNZ L0352	; If its not 3 then it skips to the same place as other error codes
L0353:  MOV A,B
        CPI 0BH		; Is the Map value read smaller than BH
        JC L0354	; If yes then skip to L0354
        CPI 0FAH	; Or is it bigger than 0FAH	
        JNC L0354	; If so then jump to L0354
        XRA A		; Otherwise its good
        STA 9010H	; And clear 9010H
L0352:  MOV A,B
        STA 8009H	; If the Map A value is good, store it in 8009H
        LDA 8004H	; Load the amplified Map A value
        STA 8006H	; And store it to 8006H
        JMP L0355	; Then jump to L0355
L0354:  LDA 8065H	
        ORA A
        JNZ L0356	; Go to 356 if there are any bits set in 8065H
        LXI B,0103H	; Otherwise call an error code, probably faulty map sensor code 3
        CALL L0039	; Calls the error routine
L0355:  LDA 3452H	; 0AH
        STA 8065H	; Store 0AH back in 8065H
        LDA 806DH
        CPI 0F3H
        JNZ L0356	; Jump to 356 if theres no error code 3, faulty Map sensor
L0351:  MVI A,0B9H	; Fail safe, if there is a Map sensor error this value just gets used
        STA 8006H
        STA 8007H
        MVI A,5DH
        STA 8009H
L0356:  LDA 8006H
        STA 8005H

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; End of Map sensor A Verification ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

        LXI H,3089H
        XCHG
        LXI B,8057H
        LDAX B
        RAR
        JNC L0357
        INX D
        INX D
        INX D
L0357:  LHLD 8017H
        LDAX D
        SUB L
        INX D
        LDAX D
        SBB H
        JNC L0358
        INX D
        XCHG
        LDA 8006H
        CMP M
        JNC L0358
        LDAX B
        ORI 01H
        STAX B
        LDA 800FH
        SUI 80H
        STA 8029H
        JMP L0359
L0358:  LDAX B
        ANI 0FEH
        STAX B
        NOP
        NOP
        NOP
L0359:  LDA 806DH
        CPI 0FBH
        JNZ L0360
        XRA A
        STA 8029H
L0360:  LHLD 8017H
        XCHG
        LXI H,327DH
        LDA 8057H
        ANI 10H
        JNZ L0361
        LXI B,0006H
        DAD B
L0361:  MVI C,03H
L0363:  MOV A,E
        SUB M
        INX H
        MOV A,D
        SBB M
        JC L0362
        INX H
        DCR C
        JNZ L0363
L0362:  LXI H,326DH
        MOV A,C
        ADD A
        MOV B,D
        MOV C,E
        MOV E,A
        MVI D,00H
        DAD D
        MOV D,M
        LDA 8057H
        ANI 10H
        MOV A,D
        JZ L0364
        INX H
        ADD M
L0364:  STA 807AH
        LHLD 32AAH
        MOV A,C
        SUB L
        MOV A,B
        SBB H
        JC L0365
        LXI H,32A8H
        LDA 8057H
        RLC
        JNC L0366	; Successful injection 
        LDA 80ADH
        CMP M		; Boost Cut, threshold stored in 32A8H (A5H)
        JC L0366
        LDA 808DH	
        ORA A
        JNZ L0367	; If any bits in 808DH are set then the injection goes ahead	
L0365:  MVI A,0FH	; This would cause the injector routines to be skipped
        JMP L0368
L0366:  LDA 32ACH	; 05H
        STA 808DH
L0367:  XRA A		; This would cause them to be run succesfully
L0368:  STA 901DH
        LXI H,80ADH
        LDA 8057H
        RLC
        JNC L0369
        LDA 32A9H
        CMP M
L0369:  RAL
        JMP L0370 	; - Bug fix by the looks

L0600:  LXI D,3296H
        LDA 8057H
        ANI 10H
        LDA 80A8H
        JNZ L0371
        LXI D,32A0H
        LDA 80A7H
L0371:  ADD L
        MOV H,A
        LDA 8011H
        MOV L,A
        MOV A,H
        NOP
        NOP
        CMP L
        JC L0372
        LDA 8001H
        MOV L,A
        LDAX D
        CMP L
        JNC L0373
        XCHG
        INX H
        MOV A,C
        SUB M
        INX H
        MOV A,B
        SBB M
        JC L0374
        JMP L0372
L0373:  INX D
        INX D
        INX D
        LDAX D
        CMP L
        INX D
        JNC L0375
        INX D
        INX D
L0375:  XCHG
        MOV A,C
        SUB M
        INX H
        MOV A,B
        SBB M
        JC L0374
L0372:  LXI H,807AH
        LDA 8006H
        CMP M
        JNC L0376
L0374:  LDA 807BH
        ORA A
        JNZ L0377
        MVI B,10H
        JMP L0378
L0376:  LDA 3268H
        STA 807BH
L0377:  MVI B,0EFH
L0378:  MOV A,B
        RRC
        LDA 8057H
        JC L0379
        ORA B
        JMP L0380
L0379:  ANA B
L0380:  STA 8057H
        RIM
        ANI 10H
        JZ L0381
        LDA 9024H
        ANI 0FH
        JNZ L0381
        LDA 9031H
        RRC
        JC L0381
        MVI A,01H
        STA 9031H
        LHLD 8098H
        MOV A,L
        ORA H
        JZ L0381
        XCHG
        MVI H,0C2H	; IC18 Timer 2, TUrns on a solenoid at Q6
        MOV M,E
        MOV M,D
L0381:  LDA 8057H
        ANI 10H
        LXI B,9028H
        JNZ L0382
        LDA 9029H
        ANI 0FH
        JZ L0383
        LXI H,807CH
        LDA 9029H
        ANI 0FH
        SUB M
        JNC L0384
        XRA A
L0384:  STA 9029H
        LHLD 8017H
        XCHG
        LHLD 329AH
        MOV A,L
        SUB E
        MOV A,H
        SBB D
        JNC L0385
        LHLD 8017H
        XCHG
        LHLD 801FH
        MOV A,E
        SUB L
        MOV L,A
        MOV A,D
        SBB H
        MOV H,A
        JC L0385
        XCHG
        LHLD 3269H
        MOV A,L
        SUB E
        MOV A,H
        SBB D
        JNC L0385
        LDAX B
        ORA A
        JNZ L0383
        MVI A,01H
        STA 9017H
L0383:  LXI H,32C9H
        LDAX B
        ANI 0FH
        ADD A
        MOV E,A
        MVI D,00H
        DAD D
        MOV A,M
        STA 807DH
        INX H
        MOV A,M
        STA 807EH
        JMP L0386
L0385:  LXI H,0000H
        SHLD 807DH
        LDA 9029H
        ANI 0FH
        JZ L0387
L0386:  LDAX B
        ANI 0FH
        MOV E,A
        LDA 807CH
        ADD E
        CPI 09H
        JC L0388
L0387:  MVI A,08H
        JMP L0388
L0382:  MVI A,04H
        STA 9029H
        XRA A
L0388:  STAX B
        LXI B,32C0H
        LXI D,3262H
        LDA 8006H
        CPI 0FAH
        JNC L0389
        LDA 8057H
        RRC
        JC L0390
        INX D
        INX D
        INX D
        LDA 901FH
        ANI 0FH
        JNZ L0391
        INX B
        INX B
L0391:  LHLD 8017H
        LDAX B
        SUB L
        INX B
        LDAX B
        SBB H
        JNC L0389
L0390:  MVI A,01H
        STA 901FH
        LHLD 8006H
        MOV A,L
        SUB H
        MOV H,A
        MOV A,L
        PUSH PSW
        MOV A,H
        JNC L0392
        CMA
        INR A
L0392:  XCHG
        CMP M
        INX H
        JNC L0393
        POP PSW
        JMP L0389
L0393:  MOV B,A
        MOV A,M
        CMP B
        JNC L0394
        MOV B,M
L0394:  INX H
        MOV A,M
        DI
        OUT 0A0H	; Some 16 bit maths
        MOV A,B
        OUT 0A2H
        MVI A,02H
        OUT 0A3H
        IN 0A1H
        MOV H,A
        IN 0A2H
        MOV L,A
        EI
        MVI A,0F0H
        ANA H
        JNZ L0395
        DAD H
        DAD H
        DAD H
        DAD H
        POP PSW
        JC L0396
        ADD H
        JNC L0397
        MVI A,0FFH
        JMP L0397
L0395:  POP PSW
        MVI A,0FFH
        JNC L0397
        INR A
        JMP L0397
L0396:  SUB H
        JNC L0397
        XRA A
L0397:  CPI 0FAH
        JC L0398
        MVI A,0F9H
L0398:  STA 8005H
        JMP L0399
L0389:  XRA A
        STA 901FH

L0399:  LDA 8006H
        STA 8007H
        LDA 8006H
        LHLD 806FH
        XCHG
        LXI H,3007H
        MOV C,M
        INX H
        MOV B,M
        CMP C
        JNC L0400
        MOV D,E
L0400:  CMP B
        JC L0401
        MOV E,D
L0401:  CALL L0088
        STA 8041H	; Stores the result of the outcome of the above L0088, either 00 or FF
        SUI 40H
        DI
        OUT 0A0H	; Some 16bit maths
        LDA 3017H
        OUT 0A2H
        MVI A,02H
        OUT 0A3H
        IN 0A1H
        RAR
        MOV H,A
        IN 0A2H
        RAR
        MOV L,A
        EI
        LXI D,0100H
        DAD D
        SHLD 8045H
        LHLD 80B7H
        XCHG
        LHLD 3305H
        LDA 8009H
        CMP L
        JNC L0402
        MOV A,L
L0402:  CMP H
        JC L0403
        MOV A,H
L0403:  SUB L
        DI
        OUT 0A0H
        MOV A,H
        SUB L
        MOV B,A
        LDA 80B9H
        SUB E
        MOV C,A
        LDA 80BAH
        SBB D
        MOV A,C
        JNC L0404
        CMA
        INR A
L0404:  PUSH PSW
        OUT 0A2H
        MVI A,02H
        OUT 0A3H
        MOV A,B
        OUT 0A0H
        MVI A,01H
        OUT 0A3H
        IN 0A3H
        RAR
        IN 0A2H
        MOV L,A
        MVI H,00H
        EI
        JNC L0405
        MVI L,0FFH
L0405:  POP PSW
        JNC L0406
        MOV A,E
        SUB L
        MOV L,A
        MOV A,D
        SBB H
        MOV H,A
        JNC L0407
        LXI H,0000H
        JMP L0407
L0406:  DAD D
        JNC L0407
        LXI H,0FFFFH
L0407:  SHLD 8042H

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; Working out a rough guide to the state of engine operations ;;;;;;;;;;;;;;;;;;;;

        LDA 901EH	; Load 901EH - Will initially be zero, its only set by this routine
        RRC		; Check bit 0
        LXI D,308FH	; D4H
        JC L0408	; If bit 0 was set then go to 408
        LXI D,3091H	; D7H

L0408:  RRC		; Check bit 1
        LHLD 306DH
        JC L0409	; If it was set then use HL = 01FBH 3700 RPM
        LHLD 306FH	; Else use HL = 01EDH 3800 RPM

L0409:  RRC		; Check bit 2
        LXI B,3071H	; 
        JC L0410	; If it was set use BC = 0E10H
        LXI B,3072H	; Else use BC = 4C0EH

L0410:  LDA 8017H	; Load the latest RPM timer value
        SUB L		; Take L from the LSB, either FB or ED. Doesnt store the value
        LDA 8018H
        SBB H		; Take H from the MSB
        XCHG		; Save this Hl used to DE so HL = 308FH or 3091H, DE = 01FBH or 01EDH
        JNC L0411	; If the revs are slower than 3700 or 3800 then jump to 411

	;;;; This means revs are higher than ~3700

        INX H		; Otherwise increment HL HL = 3090H or 3092H 
        LDA 8009H	; Load verified Map A value
        CMP M		; Compare it to whats at H, either 93H or 96H
        MVI A,40H	; Move 40H into A
        MVI D,02H	; Move 02 into D so DE = 02FBH or 02EDH 
        JC L0412	; If Map A was smaller than D4 or D7 then jump to 412

	;;;; This means Map A is reading high

        LDAX B		; Load A from 3071H or 3072H, 10H or 0EH
        MOV B,A		; Save this value to B
        LDA 8001H	; Load 8001H
        CMP B		; Compare it to 10H or 0EH
        MVI A,40H	; 
        MVI D,03H	; So DE = 03FBH or 03EDH
        JNC L0412	; Jump to 412 if 8001H (coolant?) was the same or larger than 10H or 0EH
        LDA 3075H	; So if 8001H was small, and revs High, and map A high
        MVI D,07H	; DE = 07FBH or 07EDH
        JMP L0412	; And jump to 412

L0411:  LDA 8009H	; Comes here if revs are below 3800 or 3700, HL = 308FH or 3091H
        CMP M		; A = the MSB of RPM Timer - 01H, compared to D4 or D7
        MVI A,40H	; 
        MVI D,00H	; DE = 00FBH or 00EDH
        JC L0412	; If the remained of the RPM Timer (MSB-01H) is smaller than D4 or D7 (likely unless very low RPM)
        MVI D,01H	; This means we are at very low rpm, DE = 01FBH or 01EDH

L0412:  STA 8044H	; Store 40H most/all of the time 
        MOV A,D		; Load either 0000 - Revs normal mid, 0001 - very low rpm, 0010 - high revs low MAP, 0011 - 8001H hi, hi revs, hi map, or 0111 hi revs, hi map, low 8001 into 901EH
        STA 901EH
        MVI C,30H	

;;; Waiting for a Map B converion to be done

        LXI H,9021H	; Set HL to 9021H
L0414:  MVI A,01H	; 
        ANA M		; is bit 0 set in 9021H?
        JNZ L0413	; If it is then skip out to L0413 because TPS will be converted shortly afterwards
        DCR C		; Otherwise loop for 30 tries
        JNZ L0414

        MVI A,1FH	; Command 1F
        STA 8054H
        LDA 8052H
        ANI 0F0H
        ADI 04H		; AMUX Chan 2, IC2, RAW TPS
        STA 8052H
        OUT 81H
        OUT 0B0H	; Initiate a conversion of Raw TPS and Amplified TPS
L0413:  DI		; Disable the interrupts	
        MVI A,0FEH
        ANA M		; Clear the Map B Converted bit
        MOV M,A		; Save the mask
        EI		; Enable the interrupts

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; Map Sensor B verification code ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

        LDA 80ACH	; Load the Raw Map B value
        MOV B,A		; Save it to B
        LDA 806DH
        CPI 0F4H	; Check for error codes
        JZ L0415	; Jump to 415 if there is a Faulty Map B code
        ANI 0FH
        JNZ L0416	; Jump to 416 if there are any error codes
        LDA 9010H
        ANI 0FH
        JZ L0417	; Jump to 417 if there is nothing in 9010H
        CPI 04H
        JNZ L0416	; Otherwise jump to 416 if its bigger than 4H
L0417:  MOV A,B
        CPI 0E6H	; Is Map B any higher than 0E6H?
        JNC L0418	; Jump to 418 if it is
        XRA A
        STA 9010H	; Otherwise clear 9010H
L0416:  MOV A,B		; 
        STA 80ADH	; Store verified Map B to 80ADH
        JMP L0419	; Jump to 419 if all is well
L0418:  LDA 809BH
        ORA A
        JNZ L0420	; Jump to L0420 if there are any bits set in 809BH
        LXI B,0104H
        CALL L0039	; Othwerise call it a faulty map sensor because its reading too high
L0419:  LDA 3452H
        STA 809BH	; Probably put 0AH in here This means acknowledged Map B error?
        LDA 806DH
        CPI 0F4H
        JNZ L0420	; Skip the fail safe if there isn't a Map B error
L0415:  MVI A,73H	; Fail safe, stores 73 to use instead of map B
        STA 80ADH

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; End of Map B verification code ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

L0420:  RIM		; Read the interrupt mask
        ANI 10H		; Is there a 100Hz Interrupt L0003 Pending? I think?
        JZ L0421	; If not skip to L0412
        LDA 9024H	; If yes then chec 9024H
        ANI 0FH
        JNZ L0421	; If it has bits then skip to 421
        LDA 9031H
        RRC
        JC L0421	; If 9031H has bit 0 set then skip to 421
        MVI A,01H
        STA 9031H	; If it didn't then set it
        LHLD 8098H	; Load the q6 solenoid timer value
        MOV A,L
        ORA H
        JZ L0421	; If its anything then keep going
        XCHG
        MVI H,0C2H	; Set the Q6 Solenoid Timer Going with the value that was set
        MOV M,E		
        MOV M,D

;;;;;;;;;;;;;;;;;;;; Picking which Map Sensor to Use ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;


L0421:  LDA 8057H	; Load this status register
        ANI 3FH		; Clear the top two bits
        MOV C,A		; Store it in C
        LDA 900EH	; 
        ANI 0FDH	; Clear bit 1 in 900EH
        STA 900EH	;

        LDA 8005H	; Amplified Map A sometimes
        CPI 0FAH
        JC L0422	; If amplified Map A is smaller than 0FAH then go to 422
        MOV A,C
        ORI 40H		; Set this bit if going to be using normal Map not Amped
        MOV C,A
        LDA 8009H	; Get normal Map A here if amplified Map value is maxing out
        MOV E,A		; Save the standard map value to E
        MVI D,00H
        LXI H,004CH
        DAD D		; Add 004CH to the standard Map value This an offset to get above where apmlified MAP gets to?
        XRA A
        ORA H		
        MOV A,L		; Save LSB to A 
        JNZ L0423	; If there was anything in MSB carry then skip the next two lines
        SUI 04H		; If there wasn't a carry in the addition take 04H off the L value
        JMP L0424	; Then skip to 424
L0423:  MOV A,C		; Comes here is Map A was too high to use
        ORI 80H		; Set this bit if planning on using map B
        MOV C,A
        LDA 806DH
        CPI 0F4H	; Checking for a Map B error
        JNZ L0425	; Go to L0425 if there isn't one
        LDA 900EH
        ORI 02H		; Otherwise set bit 1 in 900EH
        STA 900EH
L0425:  LDA 80ADH	; Map B verified value
        JMP L0424	; So if there isn't a Map B error and Map A is too high in the addition we use Map B and set 8057H bit 7 to tell us so

L0422:  SUI 30H		; Skips here if Amplified map A is small enough, start by taking 30H off it 30H table offset?
        JC L0426	; Jump to L0426 if it was too small
        CPI 0C0H	; Compare whats left to 0C0H
        JC L0424	; Jump if its less than this and just use it unmodified
        MOV E,A		; Otherwise store Amplified Map A - 30H in E
        RAR		; Rotate A right through carry. Does a div/2 and stores the carry bit in the MS spot?
        ANI 07H		; Mask only the lower 3 bits
        MOV D,A		; Save this to d	
        MOV A,E		; Bring back E
        ANI 0F0H	; Take only the upper 4 bits
        ADD D		; Then add D back. So this keeps the same high order bit and reduces the lower order bit
        JMP L0424
L0426:  XRA A		; If its smaller than 30H then just use 0H

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; We have picked which Map value to use XXoo oooo in 8057H XX= 0 for Amp Map A XX = 01 for Map A, XX = 11 for Map B

L0424:  MOV B,A		; Save the value we are going to use, either amplified A, shifted A or B
        ADD A
        ADD A
        ADD A
        ADD A		; A = A x 5
        STA 8078H	; Store this value in 8078, maybe truncating for use in Data Tables?
        LDA 8075H	; Load 8075H This is our RPM Bin Index
        CPI 0FH		;
        JC L0427	; If 8075H is smaller than 0FH then skip here
        DCR A		; Otherwise decrement it to make it smaller
L0427:  MOV H,A		; And store it in H
        MOV A,B		; And load our MAP vaule we chose above
        ANI 0F0H	; Select the top nibble
        ADD H		; Add this to whatever was in 8075H	So this means top nibble is MAP, bottom is RPM
        MVI H,00H
        MOV L,A		; Put the result in L
        DAD H		; Then multiply it by 2 to get 16 bit data offset
        MOV A,C		
        STA 8057H	; Then store back our modified bit mask
        PUSH H		; Save the Data Table Offset to the stack
        RLC		; Check if we set bit 7 to indicate using Map B
        JNC L0428	; Skip to 428 if we didn't

;;;; This stuff makes the offset different because we are in boost

        MVI A,01H
        STA 9035H	; Put a 1H in 9035H if we are using Map B / we are in boost
        NOP
        NOP
        NOP
        NOP
        NOP
        MVI H,01H	; Stick a 01H in H	
        MOV A,L		; Load our modified value from before
        ORI 0E0H	; Set all 3 top bits high, so makes it E or F
        MOV L,A		; Store this back in L so we get 0 1 EorF RPM

;; end of different stuff

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; Possibly reading the CVCC Injector Table?? ;;;;;;;;;;;;;;;;;;;;;;;;

L0428:  LXI D,3DE0H	; This is the offset for the final map in the data tables, doesnt have B.A for boost
        DAD D		; Then add this to 3DE0H to get an address in a data table somewhere
        CALL L0429	; Returns a 4 point interpolated data table reading starting at the above address.
        XCHG		; Saves this value in DE

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; Adds Datalogging Correction ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

        LHLD 809EH	; Loads HL from 809EH - Datalogging Correction. Will be 00 except when datalogging
        MOV A,H		; Saves H to A
        RLC		; 
        JC L0430	; Jump to 430 if bit 7 was set
        DAD D		; If it wasnt then add 809E and 809F to the interpolated reading, 0 unless datalogging
        JNC L0431	; If the value wasn't too big then go to 431
        LXI H,0FFFFH
        JMP L0431	; Otherwise max out the read in value and then go to 431
L0430:  DAD D		; Do the addition anyway
        JC L0431	; And if there is a carry go to 431 anyway
        LXI H,0000H	; Otherwise something was a bit funny? and set H to 0000H
L0431:  SHLD 8027H	; Store the interpolated Map values + the datalogging correction to 8027H and 8028H

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; End of dealing with CVCC stuff? ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

        RIM		; Read the interrupts register
        ANI 10H		; Check if any interrupts are pending
        JZ L0432	; If not then go to 432
        LDA 9024H	; If there are interrupts pending then do this stuff
        ANI 0FH		
        JNZ L0432	; Jump to 432 if there are any bits set in 9024H
        LDA 9031H	
        RRC	
        JC L0432	; Jump to 432 if bit 0 is set in 9031H
        MVI A,01H
        STA 9031H	; If there isnt then store 9031H
        LHLD 8098H	; Load H n L. Seem to be timer vals for solenoid on q6
        MOV A,L		
        ORA H		
        JZ L0432	; If its empty then skip to 432
        XCHG		; Otherwise stick it in DE
        MVI H,0C2H	; Load the Timer address
        MOV M,E		; Set the solenoid on q6 timer to what was in 8098H and 8099H
        MOV M,D		

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; Doing the Main Injector Table Read ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

L0432:  POP H		; Pop the Data Table Offset from the stack, before we molested it for boost
        LDA 901EH	; Enrichement status. The more 1's the more extra fuel is needed

;0000 - Revs Low, 0001 - very low rpm, 0010 - high revs low MAP, 0011 - 8001H hi, hi revs, hi map, or 0111 hi revs, hi map, low 8001

        RRC		; Check the LSB
        JNC L0433	; If thereis no bit in the LSB of 901Eh then go to L0433
        LDA 3074H	; Otherwise load 4CH
        MOV B,A		; Save to B
        LDA 8041H	; Dunno, initilized to 40H, gets set to either 00 or FF in the main program loop
        CMP B		; Compare 4CH to 8041H
        JC L0434	; If 8041H is smaller than 4Ch then go to L0434 otherwise do the below

L0433:  LDA 8057H
        RLC		; Checking for using Map B
        LXI D,39A0H	; This is for the 2nd map, starts at 39A0H
        JNC L0435	; If not using Map B then go read some table vals from 2nd map, NA Map
        LXI D,3BC0H	; This is for the 3rd map, starts at 3C20 because it has 3 lines of 00's
        JMP L0435	; If using map B then go read some table vals from 3rd map, Boost Map


L0434:  LDA 80ADH	; Verified Map B we get here if 8041H is smaller than 4CH and there is a bit in LS 901EH 
        MOV B,A
        ADD A
        ADD A
        ADD A
        ADD A
        STA 8078H	; Store Map B x 5 in here
        LDA 8075H	; This is our RPM value, bigger is more RPM
        CPI 0FH
        JC L0436
        DCR A		; Decrement it if its bigger than 0FH
L0436:  MOV H,A		; Save the RPM in H
        MOV A,B		; Load the MAP B value
        ANI 0F0H	; Select the top nibble
        ADD H		; Add the RPM
        MVI H,00H	; 
        MOV L,A		; Move this value into L
        DAD H		; HL = HL x 2, to get a 16 bit index value
        LXI D,3780H	; This is for the first map, starts at 37E0H cause it has 3 lines of 00's

L0435:  DAD D		; Add the offset to the maps desired. Must be even because they are 16 bit numbers
        CALL L0429	; Returns a fully 4 Point Interpolated Fuel Map Reading
        XCHG		; Which is saved in DE

        LHLD 809CH	; Load the datalogging fuel correction
        MOV A,H
        RLC
        JC L0437	; Check the MSB
        DAD D		; If there wasn't one, add the interpolated fuel value to the datalogging correction
        JNC L0438	
        LXI H,0FFFFH	; If there was a carry, just max it out
        JMP L0438
L0437:  DAD D		
        JC L0438	
        LXI H,0000H	
L0438:  SHLD 8025H	; Store main inj total fuel value here?
        MVI C,30H
        LXI H,8055H	; Conversion complete flag reg	

L0440:  MVI A,01H	; Wait 30 Loops for a conversion of Amplified TPS to be completed
        ANA M
        JNZ L0439	; Jump out when its done
        DCR C
        JNZ L0440

L0439:  DI		
        MVI A,0FEH
        ANA M	
        MOV M,A		; Ack the conversion by clearing the bit
        EI

        LXI H,8057H	; Load the register
        LDA 8015H	; Load Raw TPS
        MOV B,A		; Save it to B
        LDA 806DH	;
        CPI 0F7H	; Check for a TPS error
        JZ L0441	; If there is one skip to L0441
        ANI 0FH		
        JNZ L0442	; If there are any error codes skip to 442
        LDA 9010H
        ANI 0FH
        JZ L0443	; If there are no bits set then go to 443
        CPI 07H
        JNZ L0442	; If its bigger than 7 go to 442, esentially an error code
L0443:  MOV A,B		; Move Raw TPS back into A
        CPI 0FAH	; Commpare to FAH
        JNC L0444	; If its the same or bigger go to 444
        CPI 05H		
        JC L0444	; Else is it smaller than 05H, if so go to 444
        XRA A
        STA 9010H	; Else clear 9010H cause all is well

L0442:  MVI A,0DFH	; Jump here if there are any error codes or if all is well get here too
        ANA M
        MOV M,A		; Clear bit 5 in 8057H
        MOV A,B		; Shift the Raw TPS value back into A
        STA 8016H	; Store it to 8016H
        JMP L0445	; Jump to 445
L0444:  MVI A,20H	; RAW Map is as big or bigger than FAH, or smaller than 05H
        ORA M		; 8057H
        MOV M,A		; Set bit 2 in 8057H, this means TPS error?
        LDA 8061H	; If there is any bits set in 8061H Then there is a TPS error	
        ORA A
        JNZ L0446
        LXI B,0107H	; This means a TPS error
        CALL L0039
L0445:  LDA 3452H	; 0AH
        STA 8061H	; Store this in 8061H
        LDA 806DH
        CPI 0F7H	; Is there a TPS error code?
        JNZ L0446	; If not then jump to 446
L0441:  LXI H,8057H	; Jump to here if there is a TPS error code
        MVI A,20H
        ORA M
        MOV M,A		; Set bit 1 of 8057H if there is a TPS error
        MVI A,4DH
        STA 8016H	; Failsafe, use 4DH for the TPS
        LXI H,8080H
        SHLD 8011H	; Store 80H's to 8011,8012,8013,8014
        SHLD 8013H
L0446:  LHLD 8017H	; Load the latest RPM timer
        XCHG		; Store it in DE	
        LXI H,3057H	; Stick 3057H in HL
        LDA 804EH	; Dunno, Initialized to 80H
        CPI 80H	
        JNZ L0447	; Jump to 447 if its not 80H
        LXI H,3061H	; Else load 3061H into HL instead
L0447:  MVI C,03H	
L0449:  MOV A,M		; Either 0C6H or 0AAH
        SUB E
        INX H	
        MOV A,M		; 03C6H (1941RPM), 02B4H(2709RPM), 0218H(3498RPM) or 03AAH(1999RPM), 029EH(2799RPM), 0209H(3599) 
        SBB D
        INX H		
        JC L0448	; Some form of other RPM discreetization Working out what block of ~2000rpm its in
        INX H		; 58H(<1941RPM), 5CH(1941<rpm<4650), 64H(4650<rpm<8148) or 54H(<1999), 58H(1999<rpm<4798), 60H(4798<rpm<8397)
        DCR C
        JNZ L0449

L0448:  MOV D,M		; Save the correction? from the list above
        LXI B,304FH	
        LXI H,3044H
        LDA 804EH
        CPI 80H
        JNZ L0450
        LXI H,304BH
        LXI B,3051H
L0450:  LDA 8044H
        CPI 40H
        JNZ L0451

        LDA 8006H	; Verified, Amplified Map A
        CMP D		; Compare it to the correction thing read from above
        JNC L0452	; If Map A is larger or the same then jump to 452
        LDA 8057H
        RRC
        JC L0451	; If bit 0 of 8057H is set then jump to L0451

        JMP L0453	; Else jump to 453
L0452:  XCHG		; Save the address used above
        LHLD 8017H	; And discard our correction to read the RPM Timer again
        LDAX B		; Either 0341H(2250RPM) or 0368H(2150rpm)
        SUB L
        INX B
        LDAX B
        SBB H
        JNC L0451	; If RPM is lower than 2250 or 2150 then skip to 451

        XCHG		; Else move the address from above back into HL, either 3044H or 304BH
        LDA 8001H	; Load the verified TW Reading
        CMP M		; Compare it to 55H or 49H
        JNC L0451	; If its larger or the same then jump to 451

        LDA 806BH	; Else load 806BH
        ORA A		
        JNZ L0451	; If there are any bits set in it skip to 451
        IN 82H		; Read in Port B
        ANI 01H		; Check the 45kmhr speed switch
        JNZ L0451	; Skip to 451 if we are over/under 45kmhr

        INX H		; either 3045H or 304CH
        LDA 8006H	; Load amplified, verified Map A
        CMP M		; Compare it to 0F1H or 0E6H
        JNC L0451	; If its larger than this then jump to 451

        INX H		; either 3046H or 304DH
        MOV A,M		; either 061BH(1200RPM) or 05A2H(1300RPM)
        SUB E		; Take the current timer away from this
        INX H
        MOV A,M
        SBB D	
        JC L0451	; So jump to 451 if rpm is slower than 1200 or 1300RPM

        LDA 3054H	; A = 66H	Possibly means engine braking?
        JMP L0454	; And jump to 454
L0453:  LDA 3053H	; A = 6AH
        JMP L0454	; And jump to 454

L0451:  MVI A,80H	; Use a = 80H instead
L0454:  STA 804EH	; So this will be a 80H(normal) or a 66H or a 6AH

        RIM		; Read the interrupt mask
        ANI 10H		; Has there been a 100Hz interrupt?
        JZ L0455	; If not skip to 455
        LDA 9024H	; Otherwise update the Solenoid q6 timer
        ANI 0FH
        JNZ L0455
        LDA 9031H
        RRC
        JC L0455
        MVI A,01H
        STA 9031H
        LHLD 8098H
        MOV A,L
        ORA H
        JZ L0455
        XCHG
        MVI H,0C2H	; Timer 2 IC18
        MOV M,E
        MOV M,D

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; Looks like its trying to decide whether to run in closed loop or not ;;;;;;;;;;;;;

L0455:  LDA 806DH
        CPI 0F1H	; Is there an o2 sensor error? If so skip to 456
        JZ L0456
        LXI H,34B4H	; 52H
        LXI B,32C2H	; E0H
        LDA 8056H
        ANI 0BFH
        STA 8056H	; Clear bit 6 in 8056H
        RLC		; Check the MSb
        JC L0457	; If its set skip the next two lines
        LXI H,34B9H	; 54h at 34b9h
        LXI B,32C0H	; D5h at 32c0h
L0457:  LDA 8084H	; ?
        ORA A
        JNZ L0456	; If there is any bits set, skip to 456
        LDA 8057H	; 
        RRC	
        JC L0456	; If bit 0 is set in 8057H then skip to 456 failsafe
        LDA 8001H	; Load Coolant Value
        CMP M
        JNC L0456	; If TW is higher than 52H or 54H jump to 456
        XCHG		;
        LHLD 8017H	; Load the latest RPM Timer
        INX D		; 34B5H or 34BAH
        LDAX D
        SUB L
        INX D		; 34B6H or 34BBH
        LDAX D
        SBB H		; Take the current timer away from 0823H(900RPM) or 0823H 
        JC L0458	; If current RPM is slower than 900RPM then skip to 458
        LHLD 8021H	; Else load the main fuel value used for injection
        INX D		; 34B7H or 34BCH
        LDAX D		; 40H or 90H
        SUB L
        INX D		; 06H or 06H
        LDAX D
        SBB H
        JC L0456	; So we took our injection value away from 0640H or 0690H and if its larger 
			; we skip to the end

        LHLD 8017H	; Load our Current RPM Timer again
        LDAX B		; 32C2H or 32C0H
        SUB L
        INX B
        LDAX B		; 01E0H(3906RPM) or 01D5H(3998RPM)
        SBB H
        JNC L0458	; Jump to 458 if RPM is higher than 3906RPM or 3998RPM

        LDA 804EH
        XRI 80H
        JNZ L0459
        LDA 8057H
        ANI 10H
        JNZ L0459
        LDA 804FH
        CPI 80H
        JC L0456
        LXI H,8056H
        MVI A,40H
        ORA M
        MOV M,A
        RRC
        JNC L0456
        LHLD 8017H
        XCHG
        LXI H,34A7H
        MVI C,02H
L0461:  MOV A,E
        SUB M
        INX H
        MOV A,D
        SBB M
        INX H
        JNC L0460
        INX H
        INX H
        DCR C
        JNZ L0461
L0460:  MOV A,C
        STA 9020H
        LDA 8056H
        ANI 08H
        MOV A,M
        JZ L0462
        INX H
        MOV A,M
L0462:  STA 809AH
        MVI B,00H
        LXI H,3498H
        LDA 800BH	; Load the Raw O2 Sensor reading
        CMP M		; Compare it to 1EH
        LXI H,8056H
        JC L0463	; If its smaller than 1EH then skip the next two lines
        MVI B,08H
L0463:  MOV A,M		; Load the 8056H status reg
        MOV C,A		; Store it in C
        ANI 0F7H	; Clear the bit 3
        ORA B		; Either set bit 3 if the O2 reading is high or clear it if its low
        MOV M,A		; Save the register back
        RAL		; Check the MSb
        JC L0464	; If it was set go to 464
        MOV A,B		; Otherwise read back our 08H or 00H
        XRA C		; XOR with C, checks whether bit 3was the same as last time or not
        ANI 08H
        JZ L0465
        LDA 809AH
        MOV E,A
        MVI D,00H
        LHLD 8049H
        MOV A,B
        ORA A
        JNZ L0466
        DAD D
        JMP L0467
L0466:  MOV A,L
        SUB E
        MOV L,A
        MOV A,H
        SBB D
        MOV H,A
L0467:  CALL L0468
        SHLD 8049H
        XCHG
        LHLD 8092H
        XCHG
        CALL L0469
        PUSH PSW
        LDA 3489H
        CALL L0142
        XCHG
        LXI H,8090H
        MVI B,00H
        POP PSW
        JC L0470
        MOV A,M
        ADD C
        MOV M,A
        INX H
        MOV A,M
        ADC E
        MOV M,A
        INX H
        MOV A,M
        ADC D
        MOV M,A
        INX H
        MOV A,M
        ADC B
        MOV M,A
        JMP L0471
L0470:  MOV A,M
        SUB C
        MOV M,A
        INX H
        MOV A,M
        SBB E
        MOV M,A
        INX H
        MOV A,M
        SBB D
        MOV M,A
        INX H
        MOV A,M
        SBB B
        MOV M,A
        JMP L0471
L0464:  ORA A
        RAR
        MOV M,A
        ANI 30H
        XRI 10H
        JZ L0465
        LHLD 8092H
        LDA 34D7H
        CALL L0142
        DAD H
        JC L0472
        MOV A,C
        RLC
        JNC L0473
        INX H
        JMP L0473
L0472:  LXI H,0FFFFH
L0473:  SHLD 8049H
L0465:  LXI H,8086H
        LDA 807CH
        ADD M
        MOV M,A
        XCHG
        LXI H,348AH
        CMP M
        JC L0471
        XCHG
        MVI M,00H
        LXI H,348BH
        LDA 9020H
        ANI 0FH
        ADD A
        MOV E,A
        MVI D,00H
        DAD D
        MOV E,M
        INX H
        MOV D,M
        LHLD 8049H
        MOV A,B
        ORA A
        JNZ L0474
        DAD D
        JMP L0475
L0474:  MOV A,L
        SUB E
        MOV L,A
        MOV A,H
        SBB D
        MOV H,A
L0475:  CALL L0468
        SHLD 8049H
        JMP L0471
L0459:  LDA 8056H
        ORI 80H
        MOV C,A
        RRC
        JNC L0456
        ANI 08H
        MOV A,C
        JNZ L0476
        LDA 3486H
        STA 8087H
        MOV A,C
        ORI 10H
        JMP L0477
L0476:  ANI 20H
        MOV A,C
        JNZ L0478
        LDA 8087H
        ORA A
        MOV A,C
        JNZ L0477
        ORI 20H
L0478:  LHLD 8092H
        SHLD 8049H
L0477:  STA 8056H
        JMP L0479

L0458:  LDA 8056H	; Skip here if current RPM lower than 900RPM or higher than ~4000RPM
        RRC
        JNC L0456
        LHLD 8092H
        SHLD 8049H
        JMP L0480

L0456:  LXI H,0400H	; Come here if there is an o2 sensor error or a bunch of other crap
        SHLD 8049H
L0480:  LXI H,8056H
        MVI A,80H
        ORA M
        MOV M,A
L0471:  LDA 8056H
        ANI 0CFH
        STA 8056H
L0479:  LDA 8057H
        ANI 20H
        JNZ L0481
        LDA 9037H
        RRC
        LHLD 3107H
        JC L0482
        LHLD 3109H
L0482:  XCHG
        LHLD 8017H
        MOV A,L
        SUB E
        MOV A,H
        SBB D
        RAL
        STA 9037H
        RRC
        JC L0483
        LDA 8010H
        MOV B,A
        LDA 80A7H
        CMP B
        JC L0483
        LDA 8079H
        CMP B
        JZ L0484
        JNC L0485
        INR A
        CMP B
        JNZ L0485
L0484:  LDA 80A9H
        ORA A
        JZ L0486
        DCR A
        STA 80A9H
        JMP L0487
L0486:  LDA 8079H
        STA 80A7H
        LXI H,309FH
        ADD M
        STA 80A8H
        JMP L0488
L0485:  MOV A,B
        STA 8079H
        JMP L0488
L0483:  LDA 80A7H
        STA 8079H
L0488:  LDA 309DH
        STA 80A9H
L0487:  LHLD 8010H
        SHLD 8011H
        MOV C,L
        MOV B,H
        LHLD 8017H
        XCHG
        LHLD 31BEH
        MOV A,E
        SUB L
        MOV A,D
        SBB H
        JC L0481
        LDA 9013H
        ANI 04H
        JNZ L0481
        LDA 806DH
        CPI 0F8H
        JNZ L0489
L0481:  LXI H,0000H
        SHLD 807FH
        XRA A
        STA 8083H
        LXI H,9014H
        MVI A,0FCH
        ANA M
        MOV M,A
        JMP L0490
L0489:  MOV A,C
        SUB B
        MOV L,A
        LDA 807FH
        MOV H,A
        LXI D,9014H
        LDAX D
        RAL
        MOV C,A
        STAX D
        RRC
        JNC L0491
        XRA A
        SUB L
        MOV L,A
L0491:  SHLD 807FH
        MOV A,C
        RRC
        JC L0492
        LDA 3201H
        CMP L
        JNC L0493
        XRA A
        STA 8083H
        LDA 901BH
        ANI 0FH
        CPI 04H
        JNC L0494
        ORA A
        JNZ L0495
        LXI H,3202H
        LDA 8007H
        CMP M
        JNC L0490
        INX H
        LDA 8012H
        CMP M
        JNC L0490
        XRA A
        STA 9025H
        LHLD 8017H
        XCHG
        LHLD 31BCH
        MOV A,E
        SUB L
        MOV A,D
        SBB H
        LXI H,31C0H
        LXI D,0020H
        JNC L0496
        DAD D
L0496:  LXI D,0010H
        LDA 901AH
        ANI 08H
        JZ L0497
        DAD D
L0497:  MOV A,L
        STA 8081H
L0495:  LDA 8081H
        MOV L,A
        MVI H,31H
        LDA 807FH
        CMP M
        JC L0498
        MOV A,M
L0498:  INX H
        DI
        OUT 0A0H
        MOV A,M
        OUT 0A2H
        MVI A,02H
        OUT 0A3H
        IN 0A1H
        MOV D,A
        IN 0A2H
        MOV E,A
        EI
        INX H
        MOV C,M
        INX H
        MOV B,M
        INX H
        MOV A,L
        STA 8081H
        XCHG
        DAD B
        SHLD 802BH
        LXI H,0000H
        SHLD 805CH
        LDA 8057H
        ANI 0EFH
        STA 8057H
        LDA 901BH
        INR A
        STA 901BH
        JMP L0499
L0492:  LDA 3200H
        CMP L
        JNC L0493
        MVI A,04H
        STA 9025H
        LDA 9014H
        ANI 03H
        CPI 03H
        JNZ L0500
        LHLD 807FH
        MOV A,L
        SUB H
        JNC L0500
        JMP L0501
L0493:  LXI H,3153H
        LDA 8001H
        CMP M
        JC L0501
        LHLD 802BH
        MOV A,L
        ORA H
        JZ L0501
        LDA 9025H
        ANI 0FH
        CPI 04H
        JNC L0501
        JMP L0502
L0494:  LXI H,3153H
        LDA 8001H
        CMP M
        JC L0503
        LHLD 802BH
        MOV A,L
        ORA H
        JZ L0503
        LDA 9025H
        ANI 0FH
        CPI 04H
        JNC L0503
L0502:  MOV L,A
        MVI H,00H
        INR A
        STA 9025H
        LXI D,3154H
        DAD D
        MOV A,M
        LHLD 802BH
        CALL L0142
        DAD H
        JC L0504
        MOV A,C
        RLC
        JNC L0505
        INX H
        JMP L0505
L0504:  LXI H,0FFFFH
L0505:  SHLD 805CH
        JMP L0499
L0501:  LDA 8083H
        ORA A
        JZ L0490
        LHLD 8017H
        XCHG
        LHLD 3206H
        MOV A,E
        SUB L
        MOV A,D
        SBB H
        JC L0506
        XRA A
        STA 8083H
        JMP L0490
L0500:  LDA 3204H
        STA 8083H
L0506:  LDA 3205H
        LHLD 8025H
        DAD H
        CALL L0142
        SHLD 8025H
L0490:  XRA A
        STA 901BH
L0503:  LXI H,0000H
        SHLD 802BH
        SHLD 805CH
L0499:  LXI H,3484H
        LDA 804EH
        CPI 80H
        MOV A,M
        JC L0507
        INX H
        LDA 804FH
        CPI 80H
        MOV A,M
        JC L0507
        MVI A,80H
L0507:  STA 8050H
        LDA 900EH
        ANI 02H
        JZ L0508
        MVI A,08H
        STA 901AH
        JMP L0509
        LHLD 3208H
L0508:  LDA 8057H
        ANI 10H
        RRC
        STA 901AH
        JZ L0510
L0509:  XRA A		; jump here to set all fuel values to zero
        STA 8083H
        LXI H,0000H
        SHLD 8023H
        SHLD 8031H
        SHLD 8021H
        SHLD 80AAH
        JMP L0511
L0510:  RIM
        ANI 10H
        JZ L0512
        LDA 9024H
        ANI 0FH
        JNZ L0512
        LDA 9031H
        RRC
        JC L0512
        MVI A,01H
        STA 9031H
        LHLD 8098H
        MOV A,L
        ORA H
        JZ L0512
        XCHG
        MVI H,0C2H
        MOV M,E
        MOV M,D
L0512:  LXI H,0000H
        LDA 901DH
        ANI 0FH
        JNZ L0513
        LDA 903AH
        RRC
        JC L0513
        LDA 8056H
        RLC
        MVI A,80H
        JNC L0514
        LDA 8050H
L0514:  LHLD 8027H
        DAD H
        JC L0515
        CALL L0142
        LDA 806DH
        CPI 0F8H
        JNZ L0516
        MVI A,04H
        CALL L0142
        MOV A,H
        MOV H,L
        MOV L,C
        ORA A
        JNZ L0515
L0516:  XCHG
        LHLD 8037H
        DAD D
        JNC L0513
L0515:  LXI H,0FFFFH
L0513:  SHLD 8023H
        LHLD 804BH
        LDA 8056H
        RLC
        JC L0517
        LXI H,1000H
L0517:  XCHG
        LHLD 8094H
        CALL L0278
        MOV E,H
        MOV D,B
        LHLD 8049H
        CALL L0278
        LDA 8056H
        RLC
        JC L0518
        LDA 8073H
        MOV C,A
        MVI B,00H
        XCHG
        LXI H,34CFH
        DAD B
        MOV A,M
        XCHG
        CALL L0142
        JMP L0519
L0518:  LDA 9014H
        RRC
        JC L0520
        LDA 807FH
        MOV C,A
        LDA 3201H
        CMP C
        JNC L0520
        MVI A,80H
        JMP L0521
L0520:  LDA 804EH
        CPI 80H
        JNZ L0521
        LDA 804FH
L0521:  CALL L0142
L0519:  XCHG
        LHLD 8042H
        CALL L0278
        LDA 3074H
        MOV B,A
        LDA 8056H
        RLC
        JC L0522
        MVI A,40H
        JMP L0523
L0522:  LDA 901EH
        RRC
        LDA 8041H
        JNC L0523
        CMP B
        JNC L0523
        LDA 8044H
L0523:  CALL L0142
        SHLD 803DH
        RIM
        ANI 10H
        JZ L0524
        LDA 9024H
        ANI 0FH
        JNZ L0524
        LDA 9031H
        RRC
        JC L0524
        MVI A,01H
        STA 9031H
        LHLD 8098H
        MOV A,L
        ORA H
        JZ L0524
        XCHG
        MVI H,0C2H
        MOV M,E
        MOV M,D
L0524:  LHLD 803DH
        XCHG
        LHLD 8025H
        CALL L0278
        ORA A
        MOV A,B
        RAR
        MOV B,A
        MOV A,H
        RAR
        MOV H,A
        MOV A,L
        RAR
        MOV L,A		; Divide the result of the multiply by 2
        MOV A,B
        ORA A
        JNZ L0525	; If there was a greater than 16 bit component then number was too large and FFFF is used
        SHLD 802DH	; Store the result in 802DH. Corrected Map Value?	
        LHLD 802BH
        MOV A,H
        ORA L
        JZ L0526
        LHLD 8042H
        XCHG
        LHLD 8045H
        CALL L0278
        XCHG
        LHLD 803FH
        CALL L0278
        XCHG
        LHLD 805CH
        MOV A,L
        ORA H
        JNZ L0527
        LHLD 802BH
L0527:  MOV A,H
        ANI 7FH
        MOV H,A
        CALL L0278
        ORA A
        MOV A,B
        RAR
        MOV B,A
        MOV A,H
        RAR
        MOV H,A
        MOV A,L
        RAR
        MOV L,A
        MOV A,B
        ORA A
        JNZ L0525
L0526:  SHLD 802FH
        XCHG
        LHLD 802DH
        DAD D
        JC L0525
        XCHG
        LHLD 8037H
        DAD D
        JC L0525
        XCHG
        LHLD 302DH
        DAD D
        JC L0525
        XCHG
        LHLD 807DH
        DAD D
        JC L0525
        XCHG
        LXI H,0000H
        LDA 80A4H
        ORA A
        JZ L0528
        LHLD 3260H
L0528:  DAD D
        JC L0525
        LDA 8029H
        MOV E,A
        RLC
        MVI D,00H
        JNC L0529
        DCR D
        DAD D
        JC L0530
        JMP L0531
L0529:  DAD D
        JC L0525
L0530:  LDA 802AH
        MOV E,A
        RLC
        MVI D,00H
        JNC L0532
        DCR D
        DAD D
        JC L0533
        JMP L0531
L0532:  DAD D
        JC L0525
L0533:  LDA 8056H
        RLC
        JC L0534
        XCHG
        LDA 8073H
        MOV C,A
        MVI B,00H
        LXI H,34D3H
        DAD B
        MOV A,M
        MOV L,A
        RLC
        MVI H,00H
        JNC L0535
        DCR H
        DAD D
        JC L0534
        JMP L0531
L0535:  DAD D
        JNC L0534
L0525:  LXI H,0FFFFH
        JMP L0534
L0531:  LXI H,0000H
L0534:  SHLD 8021H	; Storing a main fuel value

        LHLD 8017H
        XCHG
        LHLD 3208H
        MOV A,L
        SUB E
        MOV A,H
        SBB D
        JNC L0536
        LHLD 80AAH
        MVI C,02H
L0537:  ORA A
        MOV A,H
        RAR
        MOV H,A
        MOV A,L
        RAR
        MOV L,A
        DCR C
        JNZ L0537
        LXI B,007DH
        DAD B
        MOV A,L
        SUB E
        MOV A,H
        SBB D
        JNC L0536
        LHLD 80AAH
        XCHG
        LHLD 8021H
        MOV A,L
        SUB E
        MOV E,A
        MOV A,H
        SBB D
        MOV D,A
        JC L0536
        LHLD 320AH
        MOV A,L
        SUB E
        MOV A,H
        SBB D
        JNC L0536
        LHLD 320CH
        MOV A,L
        SUB E
        MOV A,H
        SBB D
        JC L0538
        XCHG
L0538:  LDA 320EH
        CALL L0142
        MOV A,H
        ANI 0EH
        JNZ L0539
        MOV A,H
        MOV H,L
        MOV L,C
        DAD H
        ADC A
        DAD H
        ADC A
        DAD H
        ADC A
        MOV D,A
        MOV E,H
        LHLD 8037H
        DAD D
        JC L0539
        XCHG
        LHLD 302DH
        DAD D
        JNC L0540
L0539:  LXI H,0FFFFH
        JMP L0540
L0536:  LXI H,0000H

L0540:  SHLD 8031H
        LHLD 8021H
        SHLD 80AAH
        LDA 9017H
        ANI 01H
        JZ L0511
        XRA A
        STA 9017H
        LHLD 8021H
        SHLD 8031H
L0511:  DI
        LDA 806DH
        CPI 0F8H	; Check for TDC Sensor error
        JNZ L0541	; If there isn't one go to individual injection
        CALL BATINJ	; Call the Batch Injector Timer Loading Script
        JMP L0542
L0541:  LDA 8057H
        RRC
        RRC
        JC L0542	; Check bit 1 of 8057H, if its set then skip the injection
        CALL IDVINJ	; Call the Individual or Pair Injector Timer Loading Script
L0542:  EI		; Enable interrupts, done injecting
L0329:  DI
        LDA 9011H
        ANI 0FEH	; Clear bit 0 of 9011H
        STA 9011H
L0300:  DI		;
        POP PSW		;
        ORI 08H		;
        SIM		;
        POP PSW
        POP H
        POP D
        POP B
        EI
        RET

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; Beginning of ADCWAIT SubRoutine ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

;; A routine to wait for an analog conversion to be complete. Only used for Initialization

ADCWAIT:  MVI H,60H	; Initialise H to 60h
L0544:  LDA 8055H	; Load A from 8055h, Status reg to shown when a conversion is complete
        ANA L		; AND A with the L value passed to the subroutine (First time L = 04h) so bit 2
        JNZ L0543	; Jump if that bit is set. The conversion has been done.
        DCR H		; Otherwise decrement H and have another go
        JNZ L0544	; Have 60h goes before giving up and going onto the NOP'S
        NOP
        NOP
        NOP
        NOP
        NOP
        NOP
        NOP
L0543:  MOV A,L		; Store bitmask, L in Acc (04h first time this is called)
        LXI H,8055H	; HL = 8055h
        CMA		; Compliment the Accumulator to make a clearing bit mask
        ANA M		; Clear the bit specified in L in 8055. Ack the read.
        MOV M,A		
        RET

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; Beginning of Mystery Subroutine 78 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

;;; Makes At least 1 ADC reading, possibly 2. Messes with 8055H, maybe a status Register

;Example settings

;        LXI D,4803H
;        LXI H,2807H
;        MVI B,04H

L0078:  MVI C,30H
L0547:  DI
        LDA 8055H
        ANA B		; Is the bit set in B already set?
        JNZ L0545	; If it is then jump to the end
        LDA 8054H	; ADC Command Register
        CMP H		; Is the current command the same as the one in H?
        JNZ L0546	; Jump to 546 if it isn't (sets the command to be the one in H)
        EI
        DCR C
        JNZ L0547	; Loop for 30H loops, waiting for the conversion to finish and the ISR to run
        MOV A,D		; A = 48 in example
        ORA A
        RZ		; Return if  D = 0
        DI		; Oterwise disable interrupts to prevent ny ADCISR calls
        STA 8054H	; Set the status reg to D, 48H in example
        LDA 8052H
        ANI 0F0H
        ADD E		; AMUX Chan 1, IC1 in example.
        STA 8052H	
        OUT 81H		; Set the AMUX
        OUT 0B0H	; Trigger a conversion
        EI		; Enable the interrupts
        RET		; Jumps back to L0545 most likely unless the command was already right, then just exits.
L0546:  MOV A,H		; In exampleSet command 28 in the ADC COmmand Register
        STA 8054H
        LDA 8052H
        ANI 0F0H	
        ADD L		; AMUX chan 3, IC1 in the example
        STA 8052H
        OUT 81H		; Set the AMUX
        OUT 0B0H	; Trigger a conversion
        JMP L0078	; Recursive Call
L0545:  LXI H,8055H
        MOV A,B		; A = 04H
        CMA		; Compliment A
        ANA M		; And this with stuff at 8055H
        MOV M,A		; Clears bit set in bitmask B
        EI
        RET		; Proper return

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; Beginning of Mystery Subroutine 39 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

;; Looks like it might check for errors and set the error lights if appropriate, even reset the ECU if nesc.;;

L0039:  DI
        MOV A,C
        CPI 0FH
        JNC ECURST	; Reset ECU if C is bigger or equal than 0FH
        LDA 9010H
        ANI 0FH
        JNZ L0548	; Jump to L0548 if there is something in 9010H 
        MOV A,C		; Otherwise if there isn't, load the C command
        STA 9022H	; Store it in 9022H
        CPI 08H		
        JZ L0549	; Jump to 549 if its 8 (TDC Error)
        CPI 09H
        JZ L0549	; Jump to 549 if its 9 (CYL Error)
        EI		; Otherwise enable the interrupts and return
        RET		
L0549:  MVI A,96H
        STA 806AH	; Store 96H in 806AH
        EI
        RET		; No errors so return?

L0548:  CMP C		; Compare 9010H to C, 05H in this instance
        JNZ ECURST	; Reset the ECU if 9010H isn't the same as C
        CPI 0CH		; Compare 9010H to 0CH
        JNZ L0550	; Jump to L0550 if they are different
        MVI C,08H	; Else change C to 8H and skip to L0551
        JMP L0551
L0550:  CPI 0DH		; Compare 9010H to 0DH
        JNZ L0552	; Jump to L0552 if they are different
        MVI C,09H	; Else chance C to 9H and skip to L0551	
        JMP L0551
L0552:  CPI 0EH		; Compare 9010H to 0EH
        JNZ L0551	; Jump to L0551 if they are different
        MVI C,05H	; Else move 5H into C and go to L0551
L0551:  MOV A,C		; Load the C command into A
        CPI 08H
        JNZ L0553	; Jump to L0553 if it isn't 8
        CALL L0554	; Else run L0554 which stores some set values to RA
L0553:  MOV A,B		; Move the B command into A, likely 1
        STA 900EH	; Store this in 900eH
        RLC		; Rotate left with carry
        JNC L0555	; Jump to L0555 if there was no high bit
        MVI A,01H	
        STA 900FH	; Otherwise store a 1H in 900FH
        LXI H,8053H	; and
        MOV A,M
        ANI 0FEH	; Clear the PGMFI Lamp
        MOV M,A
        OUT 83H
L0555:  MOV A,C		; Move the C command back into a
        ORI 0F0H	
        STA 806DH	; Store it with high nibble all 1's in 806DH Possibly an error code register
        ADD A
        ADD A
        ADD A
        ADD A		; Multiply by 5
        MOV B,A		; Then save it in B
        LDA 8052H	; Load 8052H
        ANI 0FH		; Looking at error codes. Clears AMUX commands
        ORA B		; OR 8052H with the messed with C to set any error lights indicated and leaving the others on too.
        STA 8052H	
        OUT 81H
        LXI H,0000H
        SHLD 9009H	; Clear 9009H and 900BH
        SHLD 900BH
        MOV A,H
        STA 900DH	; and 900DH
        LXI H,2B78H	
        MVI B,00H	
        MOV A,C		; Move the C command into A again	
        DCR A		; Decrement
        ADD A		; x 2 because using 16 bit values
        MOV C,A		; Store it back
        DAD B		; Add it to 2B78H, somewhere in the data map address below
        MOV C,M		; If c = 5 then C now = 01H
        INX H		; Increment the pointer
        MOV A,M		; If C = 05H then A now = 05H
        LXI H,9009H
        DAD B		; Add C to 9009H, if C = 05H then HL = 900AH
        MOV M,A		; Store the 2nd value read from the Map back here.
        LXI D,9117H	; Load some initial address for a data dump
        LHLD 801FH	; These are the past counter values used for averaging purpose
        CALL Archive
        LHLD 801DH	; These are the past counter values used for averaging purpose
        CALL Archive
        LHLD 801BH	; These are the past counter values used for averaging purpose
        CALL Archive
        LHLD 8019H	; These are the past counter values used for averaging purpose
        CALL Archive
        LHLD 8017H	; These are the past counter values used for averaging purpose
        CALL Archive
        LDA 806DH
        ANI 0FH
        DCR A
        MOV C,A
        MVI B,00H
        LXI H,2B6BH
        DAD B
        MOV L,M
        MVI H,80H
        MOV C,M
        INX H
        MOV H,M
        MOV L,C
        CALL Archive
        LXI D,912BH
        LDA 80ACH
        MOV L,A
        LDA 800BH
        MOV H,A
        CALL Archive
        LDA 8010H
        MOV L,A
        LDA 8015H
        MOV H,A
        CALL Archive
        LDA 8004H
        MOV L,A
        LDA 8008H
        MOV H,A
        CALL Archive
        LXI D,9153H
        LHLD 8066H
        CALL Archive
        LHLD 8062H
        CALL Archive
        LHLD 8096H
        CALL Archive
        LHLD 8049H
        CALL Archive
        LDA 8056H
        MOV L,A
        LDA 8041H
        MOV H,A
        CALL Archive
        EI
        LXI D,9137H
        LHLD 80BFH
        CALL Archive
        LDA 800EH
        MOV L,A
        LDA 800AH
        MOV H,A
        CALL Archive
        LDA 8000H
        MOV L,A
        LDA 8002H
        MOV H,A
        CALL Archive
        LXI D,9157H
        LDA 9026H
        MOV L,A
        LDA 806DH
        MOV H,A
        CALL Archive
        RET

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; Begin Data Table ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

.ORG 2B6BH 
	MOV E,E
        NOP
        MOV H,L
        SBB E
        MOV E,C
        MOV H,B
        MOV H,C
        MOV H,H
        MOV H,M
        MOV L,B
        MOV L,C
        NOP
        NOP
        NOP
        INX B
        NOP
        NOP
        NOP
        DAD B
        LXI B,0103H
        DCR B
        LXI B,0209H
        INX B
        STAX B
        DCR B
        STAX B
        DAD B
        INX B
        INX B
        INX B
        DCR B
        NOP
        NOP
        NOP
        NOP
        ADD B
        NOP
        LXI B,0101H
        LXI B,0101H
        LXI B,8181H
        NOP
        NOP
        NOP
        MVI C,0EH
        LXI B,020EH
        MVI C,0EH
        MVI C,03H
        MVI C,0EH
        MVI C,0EH
        MVI C,0EH

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; End Data Table ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; Nibbilize and Store in 5114 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

Archive:  MVI C,04H
L0557:  XRA A
        DAD H		; HL = HL x 2
        RAL		; Store the carrybit in ACC
        DAD H		; HL = HL x 4
        RAL		; Store the carrybit in ACC
        DAD H		; HL = HL x 8
        RAL		; Store the carrybit in ACC
        DAD H		; HL = HL x F
        RAL		; Store the carrybit in ACC
        STAX D		; Store the overflows in 5114 RAM
        DCX D		; Decrement the 5114 RAM Pointer
        DCR C
        JNZ L0557	; Go through 4 times
        RET

L0554:  DI
        LDA 325CH	; 04h
        ADD A		
        ADD A		; A = 0CH
        STA 80A0H	; 80A0H = 0CH
        LDA 325EH	; 02H
        ADD A
        ADD A	
        STA 80A1H	; 80A1H = 06H
        MVI A,04H
        STA 807CH	; 807CH = 04H
        LXI B,0010H
        MVI H,0C1H
        MOV M,C		; Setting Low byte of counter 1 in IC18
        MOV M,B		; Setting High byte of counter 1 in IC18
        LXI B,0108H
        RET

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; Beginning of Mystery Subroutine 25 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

L0025:  MVI A,01H
        STA 9000H
        LHLD 8092H
        MVI C,04H
        LXI D,9004H
L0558:  XRA A
        DAD H
        RAL
        DAD H
        RAL
        DAD H
        RAL
        DAD H
        RAL
        STAX D
        DCX D
        DCR C
        JNZ L0558
        XRA A
        STA 9000H
        LHLD 8092H
        MVI C,04H
        LXI D,9008H
L0559:  XRA A
        DAD H
        RAL
        DAD H
        RAL
        DAD H
        RAL
        DAD H
        RAL
        STAX D
        DCX D
        DCR C
        JNZ L0559
        RET

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; Beginning of Mystery Subroutine 20 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

L0020:  LDA 8051H
        LXI H,3400H
        LXI B,3004H	; B =  30, C = 4
L0561:  MOV D,A
        SUB B
        JC L0560
        DCR C
        JNZ L0561
        MOV D,A
L0560:  MOV A,C
        ADD C	
        MOV C,A		; C = C x 2
        MVI B,00H
        DAD B		; H = 34H, L = 8 or less.
        MOV E,M		; Save the value to E
        INX H		; Increment H
        MOV H,M		; Save the value to H
        MOV L,E		; Move the previous value to L
        SHLD 8094H	; Store both these values to 8094, L first.
        LXI H,340AH
        RRC		; A begins as C x 2
        RRC		; A = (C / 2)
        MOV A,D
        JNC L0562	; Jump if there was no carry in the right shift. If it was 4 then there wasn't
        CMA		; Compliment ACC
        SUI 0D0H
        MVI C,00H
        JC L0563
L0562:  LXI B,0904H
L0564:  SUB B		; A = A - 9
        JC L0563
        DCR C
        JNZ L0564
L0563:  MVI B,00H
        DAD B		; Same crap as before, but adding to 340AH instead
        MOV A,M
        STA 802AH
        RET

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; Beginning of Mystery Subroutine 88 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

L0088:  DI
        SUB C		; 
        OUT 0A0H	; Operand 1 = A - C
        MOV A,D		; 
        SUB E
        JNC L0565
        CMA
        INR A
L0565:  PUSH PSW
        OUT 0A2H	; Operand 2 = D - E
        MVI A,02H	; Multiply Command
        OUT 0A3H	
        MOV A,B		
        SUB C
        OUT 0A0H	; Operand 1? = B - C
        MVI A,01H
        OUT 0A3H	; Divide Command?
        IN 0A3H
        RAR
        IN 0A2H
        MOV D,A
        EI
        JNC L0566
        MVI D,0FFH
L0566:  POP PSW
        MOV A,E
        JNC L0567
        SUB D
        RNC
        XRA A
        RET
L0567:  ADD D
        RNC
        MVI A,0FFH
        RET

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; Beginning of Mystery Subroutine 119 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

L0119:  MOV C,M
        DCX H
        MOV D,M
        DCX H
        MOV E,M
        DCX H
        MOV B,M
        SUB B
        DI
        OUT 0A0H
        MOV A,C
        SUB B
        LXI B,0004H
        DAD B
        MOV B,A
        MOV A,M
        SUB E
        MOV C,A
        INX H
        MOV A,M
        SBB D
        MOV A,C
        JNC L0568
        CMA
        INR A
L0568:  PUSH PSW
        OUT 0A2H
        MVI A,02H
        OUT 0A3H
        MOV A,B
        OUT 0A0H
        MVI A,01H
        OUT 0A3H
        IN 0A3H
        RAR
        IN 0A2H
        MOV L,A
        MVI H,00H
        EI
        JNC L0569
        MVI L,0FFH
L0569:  POP PSW
        JNC L0570
        MOV A,E
        SUB L
        MOV L,A
        MOV A,D
        SBB H
        MOV H,A
        RNC
        LXI H,0000H
        RET
L0570:  DAD D
        RNC
        LXI H,0FFFFH
        RET

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; Beginning of Fuel Map Reading Subroutine ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

;; Fuel Map Interpolation Routine
;; Reads in 4 table locations
;;
;; T1	T2
;;
;; I1   I2
;;
;; T3   T4
;;


L0429:  LDA 9035H	; Possibly sometihng to do with reading the fuel maps, looks like it reads two 16 bit numbers
        ANI 0FH		; This is set if we are using Map B
        JZ L0571
        LXI B,0020H	; Load this offset if we are using Map B
        DAD B
L0571:  MOV E,M		; LSB of first Map Value
        INX H
        MOV D,M		; MSB of 1st Map value. T1 is in DE
        INX H
        MOV C,M		; LSB of 2nd Map value
        INX H
        MOV B,M		; MSB of 2nd Map value T2
        PUSH B		; Save B Save T2
        LDA 9035H
        ANI 0FH		; If 9035 
        JZ L0572	; If we are using Map A then add 20H now to the offset for the next line
        XRA A		; Otherwise clear 9035H
        STA 9035H
        JMP L0573	; And skip the Add so both sets in boost are on the same line, no vertical interpolation
L0572:  LXI B,0020H
        DAD B
L0573:  MOV B,M		; Read the MSB first
        DCX H
        MOV C,M		; Then go back and read the LSB
        PUSH B		; And save B. Save T4
        DCX H		; Decrement again
        MOV B,M		; Take another reading
        DCX H		
        MOV L,M		; And store it in HL. Store T3	
        MOV H,B

        CALL L0574	; Vertically interpolate between T1 and T3
        MOV B,H		; Save this in BC
        MOV C,L
        POP H		; Pop T4 into HL
        POP D		; Pop T2 into DE
        CALL L0574	; Vertically interpolate between T2 and T4
        XCHG		; Save this interpolated value in DE
        MOV A,C
        SUB E
        MOV L,A
        MOV A,B
        SBB D
        MOV H,A		; HL = I1 - I2
        JNC L0575
        XRA A
        SUB L
        MOV L,A
        MVI A,00H
        SBB H
        MOV H,A
L0575:  PUSH PSW
        DAD H		; HL = HL + HL
        DAD H		; HL = HL + HL + HL
        DAD H		; HL = HL + HL + HL + HL
        DAD H		; HL = HL + HL + HL + HL + HL
        DAD H		; HL = HL + HL + HL + HL + HL + HL

        LDA 8077H	; Remainer of RPM calculation
        CALL L0142	; HL = HL x 8077H Do the same multiply and lose the lSB so its like a % multiply
        LDA 8076H	; 84H,  57H,  9EH,  7EH,  62H,  4AH,  34H,  23H,  30H,  24H,  1AH,  11H, 18H, 12H, 0DH, 0DH
			; 5990+ 5000+ 3998+ 3599+ 3200+ 2799+ 2401+ 1999+ 1600+ 1399+ 1200+ 999+ 800+ 700+ 600+ 500+
			; The plus means from that figure to the one below the next Bin up

        CALL L0142	; HL = HL x 8076H Do the same multiply and lose the lSB so its like a % multiply
        POP PSW
        JC L0576
        DAD D		; Add this back to I2
        RET
L0576:  MOV A,E		; Do this if I2 was bigger than I1
        SUB L
        MOV L,A
        MOV A,D
        SBB H
        MOV H,A
        RNC
        LXI H,0000H
        RET


L0574:  MOV A,L		; Vertical Linear Interpolation Routine
        SUB E
        MOV L,A
        MOV A,H
        SBB D
        MOV H,A		; Subtracts T1 from T3, or T2 from T4
        JNC L0577	; If there was a carry it means that T1 was bigger than T3, so answer is negative
        XRA A
        SUB L
        MOV L,A
        MVI A,00H
        SBB H
        MOV H,A
L0577:  PUSH PSW	; Save the carry flag, this indicates if T1 was bigger than T3 or T2 than T4
        LDA 8078H	; Possibly the multiplier?
        DI
        OUT 0A0H
        MOV A,L
        OUT 0A2H
        MVI A,02H
        OUT 0A3H
        IN 0A1H
        MOV L,A		; L = L x 8078H, discarding the LSB
        MOV A,H
        OUT 0A2H
        MVI A,02H
        OUT 0A3H
        MVI H,00H
        IN 0A2H		; Reads out a 16 bit result
        ADD L		; Add L to the LSB
        MOV L,A		; Store L
        IN 0A1H
        ADC H		; H is loaded with the MSB plus any carry from the L addition
        MOV H,A
        EI
        POP PSW
        JC L0578	; Checks if there was carry when it was called
        DAD D		; Add the worked out interpolation back to the base value, T1 or T2
        RET		; Return with HL storing the interpolated Y reading

L0578:  MOV A,E		; If the carry was set before then need to take away the value calced from T1 or T2 because it was bigger
        SUB L
        MOV L,A
        MOV A,D
        SBB H
        MOV H,A
        RET

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; Beginning of CYL Sensor Check and Injector INC Routine ;;;;;;;;;;;;;;;;;;;;;;

;; Checks the CYL Sensor for errors and increments the injector being fired, resets to 0 if its not right

CYLCHK:  LXI H,8067H
        XCHG
        LHLD 8017H	; Load the current RPM timer
        LXI B,0A473H	; Stick 0A473H in B
        DAD B		; Add it to the current RPM Timer
        CMC		; Compliment the carry
        RAL		; Rotate A left through carry (would have had 9013 in some form in it)
        MOV B,A		; Store this to B
        LXI H,8073H
        MOV A,M		; Injector number to be used in individual injection
        INR A		; Increment A
        ANI 03H		; And select only the lower 2 bits, limits it from 0-3
        MOV M,A		; Incremented 8073H, Means it selected the next injector
        IN 82H		; Read in Port B
        MOV C,A		; Save this to C
        LDA 806DH	; Load the error register
        CPI 0F9H	; Is there already a CYl error?
        RZ		; Return if there is
        ANI 0FH		; Otherwise are there any other errors?
        MOV A,C		; Save Port B
        JZ L0579	; If not, then jump to 579
        ANI 08H
        RZ		; Otherwise, if the CYL Latch hasnt been set, return
        OUT 60H		; Otherwise clear the CYL Latch
        MVI M,00H	; And select injector 0
        RET

L0579:  ANI 08H		; Get here if there are no errors
        JNZ L0580	; Check Bridge 1 (BR1), if its set then skip to 580 (Not set in T2)
        LDA 9010H
        ANI 0FH
        JZ L0581	; Skip to 581 if there are any pending errors
        CPI 0DH		
        JNZ L0582	; Skip to L0582 if its not a pending D error
L0581:  MOV A,B		; Something to do with 9013H
        RRC
        JC L0583	; Looking for an error D
        XRA A
        STA 9010H	; Otherwise clear 9010H
        JMP L0582	; Reset 8067H to 20H and return
L0583:  XCHG
        DCR M		; Decrement 8067H (Initialised to 02H)
        MOV A,M		; Move 8067H into A
        ORA A		
        RNZ		; If there are any bits left then return
        LXI B,010DH	; else, Call an error D, something Internal with ECU
        CALL L0039
L0582:  MVI A,20H
        STA 8067H	; And reset 8067H then return
        RET

L0580:  OUT 60H		; T2 shouldn't get here as its check Bridge 1 - Clears the CYL Latch
        XCHG		;
        MVI M,20H	; reset 8067H to 20H
        LDA 9010H
        CPI 0FDH
        JNZ L0584	
        XRA A		; If there was a pending error D then clear it
        STA 9010H
L0584:  XCHG		; 
        MOV A,M		; 8073H?
        ORA A		;
        RZ		; Return if its injector zero?
        MVI M,00H	; Else set it to injector zero
        LDA 9010H
        ANI 0FH
        JZ L0585	; No pending errors? Skip to 585H
        CPI 09H		; Is there a pending Cyl error?
        JNZ L0586	; If not then skip to the end
L0585:  MOV A,B		
        RRC
        RNC
        LDA 8074H	; Injection inhibit for x cycles register?
        ORA A
        RNZ		; Returns if injection is going to be inhibited?
        XCHG		; HL = 8067H
        DCX H		; 8066H
        DCR M		; Decrement the CYL Error counter
        MOV A,M		; Copy it to A
        ORA A
        RNZ		; If its still got something left then return
        LXI B,0109H	; Otherwise Call a CYL Error
        CALL L0039
L0586:  MVI A,0BH
        STA 8066H
        RET

;;;;;;;;;;;;;;;;;;;;;;;;; Beginning of Mystery SubRoutine 468 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

L0468:  XCHG
        LHLD 3493H 	; HL = 05E1H
        MOV A,L
        SUB E
        MOV A,H
        SBB D
        RC		; Take whatever was in HL off 05E1H  when this was called, if it carrys then return
        LHLD 3491H	; Else load 02B8H
        MOV A,L
        SUB E
        MOV A,H
        SBB D
        RNC		; And take original HL off 02B8H, return if it doesn't carry
        XCHG		; Else stick the original back in HL and 02B8H in DE
        RET

;;;;;;;;;;;;;;;;;;;;;;;;; Beginning of Batch Injector Timer Loading SubRoutine ;;;;;;;;;;;;;;;;;;;;;;;;

;; Both this and the following are called at the end of all the fuel manipulation

BATINJ:  LHLD 8023H
        MOV A,H
        ORA L
        JZ L0587	; Check if 8023HX is zero, skip to checking 8021H if it is Maybe this is boost control?
        MOV A,L
        OUT 0C0H	; Timer IC18 Counter 0 Low Byte setting
        MOV A,H
        OUT 0C0H	; Timer IC18 Counter 0 High Byte setting
L0587:  LHLD 8021H
        MOV A,H
        ORA L
        RZ		; Return if 8021HX was zero too
        
	MVI A,FUEL_MULT ; Scales the fuel value about to be used for injection
	CALL L0142	; Percentage multiply
	
        XCHG		; Else store 8021HX in DE
        LXI H,2EABH	; 0E1H, IC16 Counter/Timer 1. This is an injector Trigger Timer
        MVI C,04H
L0589:  MOV B,M 
        LDA 901DH	; Inject or Not Flag
        ANI 0FH
        JNZ L0588
        MOV A,E
        STAX B		; LSB from 8021HX into the timer
        MOV A,D
        STAX B		; MSB from 8021HX into the timer
L0588:  INX H		; Increment the timer. Goes E1,  D0, D1, E2
        DCR C		; Does the 4 injector timers
        JNZ L0589
        RET

;;;;;;;;;;;;;;;;;;;;;;;;; Beginning of Individual/Pair Injector Timer Loading SubRoutine ;;;;;;;;;;;;;;;;;;;;;;;;

;; Called after all the fuel manipulation

IDVINJ: LDA 901DH	; Flag to inject or Not
        ANI 0FH
        RNZ		; Return if this memory location doesn't have zero stored in it
        LHLD 8023H
        MOV A,H
        ORA L
        JZ L0590
        XCHG
        MVI H,0C0H
        MOV M,E		; Setting counter 0 on IC18 low byte
        MOV M,D		; Setting counter 0 on IC18 high byte
L0590:  LXI H,8074H
        XRA A
        ORA M
        JZ L0591
        DCR M
        RET
L0591:  LXI H,2EABH	; 0E1H, IC16 Counter/Timer 1. This is an injector Trigger Timer
        LDA 8073H
        MVI B,00H
        MOV C,A
        DAD B		; Add the offset from 8073H to the timer address. To select a specific timer
        MOV E,M		; Save this timer in E
        DCX H		
        MOV D,M		; Decrement and save the next lower timer in D
        LHLD 8031H	; 
        MOV A,H	
        ORA L
        JZ L0592	; If there is nothing in 8031H then skip to setting 8021H. 8031H must be if two injector timers are to be set
        
	MVI A,FUEL_MULT ; Scales the fuel value about to be used for injection
	CALL L0142	; Percentage multiply
	
	XCHG
        MOV M,E
        MOV M,D
        XCHG
L0592:  LHLD 8021H
        MOV A,H
        ORA L
        RZ		; Return if the 8021H value is zero
        MOV D,E

	MVI A,FUEL_MULT ; Scales the fuel value about to be used for injection
	CALL L0142	; Percentage multiply
	
	XCHG		; Move the initial timer value into D and swap into HL
        MOV M,E		; Store 8021H to the timer specified
        MOV M,D
        RET
	.DB 0E2H
	.DB 0E1H
	.DB 0D0H
	.DB 0D1H
	.DB 0E2H

;;; Room for some extra code here

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; Beginning of Mystery Subroutine 211 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

;;;;; Looks like it might be a bug fix, a bit of extra code just chucked in.

.org 2F00H

L0211:  STA 902AH
        LXI H,805AH
        MOV A,M
        ORA A
        JZ L0595
        DCR M
L0595:  LXI H,8059H
        MOV A,M
        ORA A
        JZ L0596
        DCR M
L0596:  LXI H,8064H
        MOV A,M
        ORA A
        JZ L0597
        DCR M
        JMP L0597	; Goes back to where it was called

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; Beginning of Mystery Subroutine 370 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

;;;;; Looks like it might be a bug fix, a bit of extra code just chucked in.

L0370:  STA 903AH
        LXI D,3289H
        LDA 903BH
        RRC
        JC L0598
        LXI D,328BH
L0598:  LDAX D
        SUB C
        INX D
        LDAX D
        SBB B
        RAL
        STA 903BH
        RRC
        LDA 328DH
        JC L0599
        LDA 328EH
L0599:  MOV L,A
        JMP L0600

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;; End of Subroutines and ISR's ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; Beginning of Data Tables ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

.org 3000H
	.DB 00H
        .DB 4EH
        .DB 52H
        .DB 9EH
	.DB 0C9H
        RST 6
        RST 7
        SUB H
        RST 7
        MOV B,B
        MOV B,B
        MOV B,E
        MOV C,L
        MOV D,E
        MOV L,L
        MOV L,L
        MOV B,B
        MOV B,B
        MOV C,D
        MOV E,L
        HLT
        ADD B
        ADD B
        .DB 18H ;UNRECOGNIZED
        NOP
        PUSH B
        LXI B,0C570H
        LXI B,0E1A0H
        NOP
        RNZ
        SBB H
        NOP
        RPO
        MOV L,C
        NOP
        CPI 4AH
        NOP
        RST 7
        MOV C,D
        NOP
        MVI A,00H
        NOP
        NOP
        NOP
        NOP
        NOP
        NOP
        NOP
        NOP
        NOP
        NOP
        NOP
        NOP
        NOP
        NOP
        NOP
        NOP
        NOP
        NOP
        NOP
        NOP
        NOP
        MOV D,L
        POP PSW
        DCX D
        MVI B,00H
        NOP
        NOP
        MOV C,C
        ANI 0A2H
        DCR B
        MOV B,C
        INX B
        MOV L,B
        INX B
        MOV L,D
        MOV H,M
        SUB M
        NOP
        ADI 03H
        MOV E,B
        ORA H
        STAX B
        MOV E,H
        .DB 18H ;UNRECOGNIZED
        STAX B
        MOV H,H
        MOV L,E
        XRA D
        INX B
        MOV D,H
        SBB M
        STAX B
        MOV E,B
        DAD B
        STAX B
        MOV H,B
        MOV H,A
        NOP
        NOP
        EI
        LXI B,01EDH
        .DB 10H ;UNRECOGNIZED
        MVI C,4CH
        MOV C,H
        MOV B,B
        MOV D,L
        XRA B
        MVI B,30H
        ADD A
        MOV C,C
        ANA D
        DCR B
        DAD SP
        ADC C
        INX H
        .DB 08H ;UNRECOGNIZED
        NOP
        NOP
        XTHL
        NOP
        NOP
        NOP
        INX B
        MOV D,E
        RLC
        ADC B
        SUB A
        MVI B,94H
	.DB 0D4H
	.DB 93H
	.DB 0D7H
        SUB M
        NOP
        NOP
        MOV D,L
        MOV E,C
        MOV H,M
        MOV H,M
        MOV E,D
        MOV E,D
        MOV E,D
        MOV H,B
        DAD D
        SIM
        STAX B
        INR D
        INR E
        MVI H,2DH
        DCR M
        MOV C,B
        MOV E,D
        MOV M,B
        ADC M
        ADC M
        ADC M
        ADC M
        ADC D
        ADD M
        ADD M
        ADD M
        ADC M
        ADC M
        ADC M
        ADC M
        ADC D
        ADD M
        ADD M
        ADD M
        ADC L
        ADC L
        ADC L
        ADC L
        ADC C
        ADD L
        ADD L
        ADD L
        ADC H
        ADC H
        ADC H
        ADC H
        ADC B
        ADD H
        ADD H
        ADD H
        ADC E
        ADC E
        ADC E
        ADC E
        ADD A
        ADD E
        ADD E
        ADD E
        ADC E
        ADC E
        ADC E
        ADC E
        ADD M
        ADD B
        ADD B
        ADD B
        ADC E
        ADC E
        ADC E
        ADC E
        ADD M
        ADD B
        ADD B
        ADD B
        ADC E
        ADC E
        ADC E
        ADC E
        ADD M
        ADD B
        ADD B
        ADD B
        MOV B,B
        SBB H
        RPE
        ADD B
        NOP
        NOP
        NOP
        NOP
        NOP
        NOP
        NOP
        NOP
        NOP
        NOP
        NOP
        NOP
        NOP
        NOP
        NOP
        NOP
        NOP
        NOP
        NOP
        NOP
        NOP
        NOP
        NOP
        NOP
        NOP
        LXI B,0AA60H
        INX B
        MOV D,H
        INX B
        STA 0FF02H
        MOV B,B
        NOP
        NOP
        NOP
        NOP
        NOP
        NOP
        NOP
        NOP
        NOP
        NOP
        NOP
        NOP
        NOP
        NOP
        NOP
        NOP
        NOP
        NOP
        NOP
        NOP
        NOP
        NOP
        NOP
        NOP
        NOP
        NOP
        RIM
        DCR H
        CMA
        LDA 07FFH
        RLC
        NOP
        NOP
        NOP
        NOP
        ANA D
        DCR B
	.DB 0E2H
	.DB 04H
	.DB 030H
        NOP
        ADD B
        NOP
        NOP
        NOP
        NOP
        NOP
        NOP
        NOP
        NOP
        NOP
        NOP
        NOP
        NOP
        NOP
        INR B
        NOP
        ANA C
        SBB M
        ANA D
        DCR B
        ANA D
        DCR B
        MOV A,L
        ADD D
        MOV H,H
        MOV C,C
        MOV B,B
        RIM
        .DB 10H ;UNRECOGNIZED
        .DB 08H ;UNRECOGNIZED
        DCR D
        MOV C,L
        RZ
        MOV C,C
        CALL L0603
        XRI 02H
        DCR H
        XRI 02H
        PUSH D
        LXI B,07FAH
        NOP
        RST 7
        RST 7
        INX SP
        LXI B,0022H
        SHLD 2A00H
        NOP
        INR M
        NOP
        MOV B,E
        NOP
        MOV E,C
        NOP
        DCR L
        NOP
        NOP
        POP PSW
        POP PSW
	.DB 0C3H
	.DB 09EH
	.DB 09EH
        MOV A,D
        MOV E,H
        ORA M
        ADD A
        LXI B,0177H
        MOV E,L
        MOV A,M
        MOV E,A
        MOV A,H
        NOP
        NOP
        NOP
        NOP
        NOP
        NOP
        NOP
        NOP
        NOP
        NOP
        NOP
        NOP
        NOP
        NOP
        NOP
        NOP
        NOP
        NOP
        NOP
        NOP
        NOP
        NOP
        NOP
        NOP
        NOP
        NOP
        NOP
        NOP
        NOP
        NOP
        NOP
        NOP
        NOP
        NOP
        NOP
        NOP
        NOP
        NOP
        NOP
        NOP
        NOP
        NOP
        NOP
        NOP
        NOP
        NOP
        NOP
        NOP
        SIM
        INR B
        PUSH D
        LXI B,22A0H
        NOP
        NOP
        ANA B
        STAX D
        NOP
        NOP
        ANA B
        INX D
        NOP
        NOP
        ANA B
        RRC
        NOP
        NOP
        MOV B,H
        STAX D
        XRI 02H
        SHLD 0FA24H
        NOP
        NOP
        NOP
        NOP
        NOP
        NOP
        NOP
        NOP
        NOP
        ANA B
        INR C
        NOP
        NOP
        ANA B
        MVI C,00H
        NOP
        ANA B
        RRC
        NOP
        NOP
        ANA B
        INR C
        NOP
        NOP
        SHLD 0FA24H
        NOP
        SHLD 0FA24H
        NOP
        SHLD 0024H
        NOP
        NOP
        NOP
        NOP
        NOP
        STAX B
        STAX B
        RST 7
        RST 7
        MVI E,70H
        ANA D
        DCR B
        SBB L
        .DB 08H ;UNRECOGNIZED
        INR C
        NOP
        NOP
        INR B
        .DB 28H ;UNRECOGNIZED
        INR D
        INR H
	.DB 0F4H
	.DB 03H
	.DB 9EH
        STAX B
        MOV C,C
        ADD E
        MOV A,L
        ADD B
        MOV H,H
        NOP
        ADD A
        SUB M
        NOP
        ANA C
        RZ
        NOP
        RST 7
        RZ
        NOP
        SBB M
        INR B
        STAX B
        NOP
        LDA 0C987H
        RST 4
        RST 6
        RST 7
        ADD B
        ADD M
        ADD B
        ADD M
        MOV D,B
        MOV E,C
        NOP
        DCR L
        ANA B
        STAX D
        RP
        MVI C,0F0H
        MVI C,0F3H
        STAX B
        DI
        STAX B
        DI
        STAX B
        DI
        STAX B
        DI
        STAX B
        DI
        STAX B
        DI
        STAX B
        MVI A,49H
        MOV L,D
        .DB 18H ;UNRECOGNIZED
        MOV B,B
        XRA B
        MOV D,B
        STAX D
        .DB 10H ;UNRECOGNIZED
        MOV B,B
        NOP
        CMA
        MVI E,00H
        MVI B,2FH
        RRC
        DCR L
        INR B
        NOP
        STAX B
        NOP
        MOV H,B
        NOP
        NOP
        INX B
        .DB 28H ;UNRECOGNIZED
        NOP
        .DB 18H ;UNRECOGNIZED
        .DB 28H ;UNRECOGNIZED
        STAX B
        RP
        NOP
        NOP
        NOP
        NOP
        NOP
        MOV D,H
        DCX B
        MOV E,H
        LXI D,1463H
        NOP
        NOP
        NOP
        NOP
        NOP
        NOP
        NOP
        NOP
        .DB 18H ;UNRECOGNIZED
        STAX B
        ORA H
        STAX B
        ADI 03H
        DAD B
        STAX B
        SBB M
        STAX B
        XRA D
        INX B
        ANA C
        LXI B,01B0H
        STAX B
        INR D
        NOP
        NOP
        NOP
        NOP
        NOP
        NOP
        .DB 02H
        .DB 5DH
        .DB 54H
        .DB 03H
        .DB 49H
        .DB 9EH
        .DB 08H 
        .DB 3BH
        .DB 05H
        NOP
        NOP
        .DB 5BH
        .DB 0DH
        .DB 03H
        .DB 41H
        .DB 1BH
        .DB 06H
	.DB 94H
        .DB 04H
        .DB BOOST_CUT	; 32A8H Boost Cut Threshold
        .DB 58H
        .DB 1CH
        .DB 01H
	.DB 05H
	NOP
        NOP
        NOP
        NOP
        NOP
        NOP
        NOP
        NOP
        NOP
        NOP
        NOP
        NOP
        NOP
        NOP
        NOP
        NOP
        NOP
        NOP
        NOP
        PUSH D
        LXI B,01E0H
        RST 4
        CMP A
        MOV B,B
        DCR A
        LDA 02EEH
        XRI 02H
        XRI 02H
	.DB 0FAH
	.DB 00H
	.DB 0FAH
        NOP
	.DB 0FAH
	.DB 00H
	.DB 0FAH
        NOP
        NOP
        NOP
        NOP
        NOP
        NOP
        SBB L
        LXI B,9D40H
        LXI B,0D470H
        LXI B,00A1H
        STAX B
        PUSH D
        STC
        STAX B
        RM
        ADD H
        STAX B
        RST 7
        ADD H
        STAX B
        NOP
        OUT 01H
        MOV B,B
        OUT 01H
        MOV M,B
	.DB 0ECH
	.DB 01H
	.DB 0A1H
        NOP
        STAX B
        PUSH D
        DAD D
        STAX B
        RM
        INR A
        STAX B
        RST 7
        INR A
        STAX B
        .DB 38H ;UNRECOGNIZED
        MOV A,M
        XRI 02H
        ADD B
        NOP
        SIM
        NOP
        MOV B,B
        SBB H
        .DB 18H ;UNRECOGNIZED
        STAX B
        NOP
        INR B
        .DB 10H ;UNRECOGNIZED
        NOP
        RPO
        MVI L,0A0H
        LXI B,0200H
        .DB 18H ;UNRECOGNIZED
        NOP
        RPO
        MVI L,00H
        STAX B
        .DB 18H ;UNRECOGNIZED
        NOP
        RPO
        MVI L,00H
        NOP
        NOP
        NOP
        NOP
        NOP
        NOP
        NOP
        NOP
        NOP
        NOP
        NOP
        NOP
        NOP
        NOP
        NOP
        NOP
        NOP
        NOP
        NOP
        NOP
        NOP
        NOP
        NOP
        NOP
        NOP
        NOP
        NOP
        NOP
        NOP
        NOP
        NOP
        NOP
        NOP
        NOP
        NOP
        NOP
        NOP
        NOP
        NOP
        NOP
        NOP
        NOP
        NOP
        NOP
        NOP
        NOP
        NOP
        NOP
        NOP
        NOP
        NOP
        NOP
        NOP
        NOP
        NOP
        NOP
        NOP
        NOP
        NOP
        NOP
        NOP
        NOP
        NOP
        NOP
        NOP
        NOP
        NOP
        NOP
        NOP
        NOP
        NOP
        NOP
        NOP
        NOP
        NOP
        NOP
        NOP
        NOP
        NOP
        NOP
        NOP
        NOP
        NOP
        NOP
        NOP
        NOP
        NOP
        NOP
        NOP
        NOP
        NOP
        NOP
        NOP
        NOP
        NOP
        NOP
        NOP
        NOP
        NOP
        NOP
        NOP
        NOP
        NOP
        NOP
        NOP
        NOP
        NOP
        NOP
        NOP
        NOP
        NOP
        NOP
        NOP
        NOP
        NOP
        NOP
        NOP
        NOP
        NOP
        NOP
        NOP
        NOP
        NOP
        NOP
        NOP
        NOP
        NOP
        NOP
        NOP
        NOP
        NOP
        NOP
        NOP
        NOP
        NOP
        NOP
        NOP
        NOP
        NOP
        NOP
        NOP
        NOP
        NOP
        NOP
        NOP
        NOP
        NOP
        NOP
        NOP
        NOP
        NOP
        NOP
        NOP
        NOP
        NOP
        NOP
        NOP
        NOP
        NOP
        NOP
        NOP
        NOP
        NOP
        NOP
        NOP
        NOP
        NOP
        NOP
        NOP
        NOP
        NOP
        NOP
        NOP
        NOP
        NOP
        NOP
        NOP
        NOP
        NOP
        NOP
        NOP
        NOP
        NOP
        NOP
        NOP
        NOP
        NOP
        NOP
        NOP
        NOP
        NOP
        NOP
        NOP
        NOP
        NOP
        NOP
        NOP
        NOP
        NOP
        NOP
        NOP
        NOP
        NOP
        NOP
        NOP
        NOP
        NOP
        NOP
        NOP
        NOP
        NOP
        NOP
        NOP
        NOP
        NOP
        NOP
        NOP
        NOP
        ADC A
        SHLD 2148H
        NOP
        RIM
        CMP B
        MVI E,71H
        DCR E
        MOV H,M
        INX SP
        NOP
	.DB 0CDH
	.DB 09AH
	.DB 0BEH
        LXI B,01D5H
        NOP
        ADD H
        MOV D,A
        SBB M
        MOV A,M
        MOV H,D
        MOV C,D
        INR M
        INX H
        SIM
        INR H
        LDAX D
        LXI D,1218H
        DCR C
        DCR C
        DAD SP
        LXI B,003EH
        MOV E,M
        NOP
        INR M
        NOP
        MOV B,C
        NOP
        MOV D,H
        NOP
        MOV L,A
        NOP
        SBB L
        NOP
	.DB 0EAH
	.DB 00H
	.DB 0A8H
        NOP
        RST 3
        NOP
        DAD SP
        LXI B,01D4H
        MOV C,A
        LXI B,01BFH
        MOV M,C
        STAX B
        NOP
        LXI B,9900H
        NOP
        RST 0
        NOP
        PUSH B
        NOP
        RST 4
        .DB 0D9H ;UNRECOGNIZED
        ORA L
        ADD A
        LDA 0F0AH
        NOP
        LDAX B
        .DB 28H ;UNRECOGNIZED
        NOP
        MOV D,B
        .DB 28H ;UNRECOGNIZED
        ADD D
        ANI 30H
        MOV A,C
        NOP
        STAX B
        NOP
        MOV D,L
        XRA D
        NOP
        NOP
        NOP
        NOP
        NOP
        NOP
        NOP
        NOP
        NOP
        NOP
        NOP
        NOP
        NOP
        NOP
        NOP
        NOP
        NOP
        NOP
        NOP
        NOP
        NOP
        NOP
        NOP
        NOP
        NOP
        NOP
        NOP
        NOP
        NOP
        XRA B
        MVI B,0A2H
        DCR B
        ADD B
        SUB E
        DCR B
        INR A
        NOP
        MOV B,B
        INR B
        INR B
        NOP
        INR B
        NOP
        INR B
        NOP
        CMP B
        STAX B
        POP H
        DCR B
        RAL
        NOP
        NOP
        MVI E,00H
        NOP
        NOP
        NOP
        NOP
        NOP
        XRA M
        LXI B,00FAH
        RP
        NOP
        STA 1A00H
        MVI B,15H
        SHLD 0271H
        DCR D
        SHLD 2222H
        .DB 08H ;UNRECOGNIZED
        LDAX B
        MOV C,E
        MOV D,D
        INX H
        .DB 08H ;UNRECOGNIZED
        MOV B,B
        MVI B,54H
        INX H
        .DB 08H ;UNRECOGNIZED
        SUB B
        MVI B,00H
        NOP
        NOP
        NOP
        NOP
        NOP
        NOP
        NOP
        NOP
        NOP
        NOP
        NOP
        NOP
        NOP
        NOP
        NOP
        NOP
        ADD C
        ADD C
        ADD B
        ADD C
        NOP
        NOP
        NOP
        NOP
        ADD M
        NOP
        NOP
        NOP
        NOP
        NOP
        NOP
        NOP
        NOP
        NOP
        NOP
        NOP
        NOP
        NOP
        NOP
        NOP
        NOP
        NOP
        NOP
        NOP
        NOP
        NOP
        NOP
        NOP
        NOP
        NOP
        NOP
        MOV D,E
        RLC
        MOV H,M
        NOP
        INX B
        NOP
        NOP
        NOP
        NOP
        NOP
        NOP
        NOP
        NOP
        NOP

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; End oF This Block of Data Tables ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;



;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; Beginning of More Code, Subroutine 309 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

L0309:  MOV E,M
        INX H
        MOV D,M
        INX H
        MOV A,M
        INX H
        MOV H,M
        MOV L,A
        XCHG
        PUSH D
        CALL L0469
        MOV E,B
        MOV A,C
        CALL L0142
        MOV B,H
        MOV H,C
        MOV C,L
        MOV A,E
        CALL L0610
        MOV D,A
        MOV B,E
        CALL L0046
        MOV C,A
        MOV A,L
        SUB C
        MOV B,A
        MOV C,H
        MOV A,E
        CALL L0610
        MOV E,A
        POP H
        DAD D
        MOV B,H
        MOV E,L
        LDA 8050H
        CALL L0142
        MOV A,C
        MOV C,E
        RAL
        MOV A,L
        RAL
        MOV E,A
        MOV A,H
        RAL
        MOV D,A
        LHLD 8037H
        DAD D
        JNC L0611
        LXI H,0FFFFH
L0611:  MOV D,B
        MOV E,C
        RET

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; Mysterious Subroutine 469 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

L0469:  MOV A,L
        SUB E
        MOV L,A
        MOV A,H
        SBB D
        MOV H,A
        RNC
        XRA A
        SUB L
        MOV L,A
        MVI A,00H
        SBB H
        MOV H,A
        RET

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; Mysterious Subroutine 46 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

;;;; Possibly a B x ACC subroutine

L0046:  DI		; Possibly B x ACC
        OUT 0A0H	; Multiply Divide Chip, First Operantd
        MOV A,B		;
        OUT 0A2H	;
        MVI A,02H	; Multiply Command
        OUT 0A3H	;	
        IN 0A1H		;
        MOV B,A		;
        IN 0A2H		;
        EI		;
        RET		; Result stored in ACC and B

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 16 bit Multiply Routine ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

;;;; HL x DE with result in BHL

L0278:  DI
        MOV A,L
        OUT 0A0H
        MOV A,E
        OUT 0A2H
        MVI A,02H
        OUT 0A3H
        IN 0A1H
        MOV B,A
        IN 0A2H
        MOV C,A
        MOV A,D
        OUT 0A2H
        MVI A,02H
        OUT 0A3H
        IN 0A2H
        ADD B
        MOV L,A
        MVI B,00H
        IN 0A1H
        ADC B
        MOV B,A
        MOV A,H
        OUT 0A0H
        MOV A,E
        OUT 0A2H
        MVI A,02H
        OUT 0A3H
        IN 0A2H
        ADD L
        MOV L,A
        IN 0A1H
        ADC B
        MOV E,A
        MVI A,00H
        ADC A
        MOV B,A
        MOV A,D
        OUT 0A2H
        MVI A,02H
        OUT 0A3H
        IN 0A2H
        ADD E
        MOV H,A
        IN 0A1H
        ADC B
        MOV B,A
        EI
        RET

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; Mysterious, Mathematical Subroutine 142 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

;;;; Possibly a generic 16bit multiply Routine

L0142:  DI		; 16bit Multiply Routine
        OUT 0A0H	; First operand is A
        MOV A,L
        OUT 0A2H	; Second Operand is L
        MVI A,02H	; Multiply Command
        OUT 0A3H
        IN 0A1H
        MOV L,A		; L = A x L
        IN 0A2H
        MOV C,A		; any carry from A x L is in C
        MOV A,H
        OUT 0A2H
        MVI A,02H	; Another Multiply
        OUT 0A3H
        MVI H,00H
        IN 0A2H
        ADD L
        MOV L,A		; L = (A x L) + LSB of (H x A)
        IN 0A1H
        ADC H		; MSB of H x A loaded into H plus any carry from above
        MOV H,A
        EI
        RET

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; Mysterious, Mathematical Subroutine 610 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

;;;; Possibly a generic 16bit Divide Routine

L0610:  DI		; 16bit Divide Routine
        OUT 0A0H	; First operand
        MOV A,C
        OUT 0A2H	; Second operand
        MOV A,B
        OUT 0A1H	
        MVI A,01H	; Divide routine
        OUT 0A3H
        IN 0A3H
        RAR
        IN 0A2H		; In quotient
        EI
        RET

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; Analog To Digital Converter ISR ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
.ORG 3600H
ADCISR: DI		; A2D ISR
        PUSH H		; Saves H
        PUSH PSW	; Saves the PSW
        LDA 8054H	; Loads a command maybe?
        MOV L,A		; Saves the data from above in L
        MVI H,36H	; Move 36H into H
        PUSH H		; Save H	Uses the RET command to load the next address from the Stack
        CPI 12H		; Compare 12H to 8054H RAM (28H for first conversion inmain program loop)
        JC ECURST	; Reset the ECU if 8054H RAM is less than 12H
        IN 0B0H		; Read A2D Data in
        RET		; Return
        
	STA 8010H	; Instruction 12H AMUX Chan 1, IC2 - 5th and Final in Small loop. 1.666 TPS, Amplified
        LXI H,8055H	; Loads 8055H into HL
        MVI A,01H	; Set bit 0 in 8055 XXXX XXX1
        ORA M		
        MOV M,A		
        JMP L0612	; Done, Skips to RET
        
	STA 8015H	; Instruction 1FH AMUX Chan 2, IC2 - 4th in small loop. Throttle Position Sensor RAW
        LXI H,1202H
        JMP L0613

        STA 8000H	; Instruction 28H - AMUX chan 3, IC1     1st In set of readings, Coolant Temp
        LXI H,8055H
        MVI A,04H	; Set bit 2 in 8055 XXXX X1XX
        ORA M
        MOV M,A
        LXI H,4803H	
        JMP L0613

        STA 800AH	; Instruction 38H - AMUX Channel 3, IC2     3rd In set of readings, 0.38 x Batt Voltage. Can Measure up to 13V
        LXI H,8055H
        MVI A,08H	; Set bit 3 in 8055 XXXX 1XXX
        ORA M
        MOV M,A
        LXI H,9A0AH
        JMP L0613

        STA 800EH	; Instruction 48H - AMUX Channel 1, IC1     2nd In set of readings, IMA RAW
        LXI H,8055H
        MVI A,10H	; Set bit 4 in 8055 XXX1 XXXX
        ORA M
        MOV M,A
        LXI H,3806H
        JMP L0613

        STA 80ACH	; Instruction 58H - AMUX Channel 6, IC2 3rd In small loop, MAP B
        LXI H,9021H
        MVI A,01H	; Set bit 1 in 9021 XXX1
        ORA M
        MOV M,A
        LXI H,1F04H
        JMP L0613

        MOV H,A		; Instruction 68H - AMUX Channel 4, IC2    6th In set of readings, 2nd in small loop, MAP A	
        LDA 9011H
        RRC
        MOV A,H
        JC L0614	; If bit 1 in 9011 is set then do the small loop with Map B and TPS, otherwise continue as normal
        STA 800CH
        LXI H,8055H
        MVI A,20H	; Set bit 5 in 8055 XX1X XXXX
        ORA M
        MOV M,A
        LXI H,0BA01H
        JMP L0613

L0614:  STA 8008H	; MAP A if the 9011H flag is set, Possibly if in boost, still 2nd in small loop
        LXI H,9021H
        MVI A,02H	; Set bit 2 in 9021 XX1X
        ORA M
        MOV M,A
        LXI H,580CH
        JMP L0613

        STA 8004H	; Instruction 91H - AMUX Channel 0, IC2 Amplified Map A, Start of small loop
        LXI H,6808H
        JMP L0613

        STA 800BH	; Instruction 9AH - AMUX Channel 5, IC2    4th In set of readings, O2 Sensor
        LXI H,8055H
        MVI A,80H	; Set bit 7 in 8055 1XXX XXXX
        ORA M
        MOV M,A
        LXI H,0AA05H
        JMP L0613

        STA 8002H	; Instruction 0AAH - AMUX Channel 2, IC1    5th In set of readings, Air Temp
        LXI H,8055H
        MVI A,02H	; Set bit 1 in 8055 XXXX XX1X
        ORA M
        MOV M,A
        LXI H,6808H
        JMP L0613

        STA 8051H	; Instruction 0BAH - AMUX Channel 0, IC1    7th and Final In set of readings, 0.46 x 5V LINE
        LXI H,8055H
        MVI A,40H	; Set bit 6 in 8055 X1XX XXXX
        ORA M
        MOV M,A
        JMP L0612	; Done, Skips to RET

L0613:  MOV A,H
        STA 8054H	; Store the next Command in the set if it is tobe a rolling read.
        LDA 8052H
        ANI 0F0H
        ADD L		; L is the appropriate AMUX channel
        STA 8052H
        OUT 81H		; Set the AMUX
        OUT 0B0H	; Trigger another conversion
L0612:  POP PSW		; Skip to here for a single conversion
        POP H
        EI
        RET		; Release control

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; End of All Code ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; Start of the Rest of the Data Tables ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;


.org 37E0H        
	.DB 60H
        .DB 06H
        .DB 60H
        .DB 06H
        .DB 60H
        .DB 06H
        .DB 60H
        .DB 06H
        .DB 60H
        .DB 06H
        .DB 60H
        .DB 06H
        .DB 60H
        .DB 06H
        .DB 60H
        .DB 06H

.org 37F0H	
	.DB 60H
        .DB 06H
        .DB 80H
        .DB 06H
        .DB 60H
        .DB 06H
        .DB 70H
        .DB 06H
        .DB 70H
        .DB 06H
        .DB 70H
        .DB 06H
        .DB 20H
        .DB 06H
        .DB 10H
        .DB 06H
        
.org 3800H	
	.DB 0F0H
        .DB 07H
        .DB 0F0H
        .DB 07H
        .DB 0F0H
        .DB 07H
	.DB 0F0H
        .DB 07H
	.DB 0F0H
        .DB 07H
	.DB 0F0H
        .DB 07H
	.DB 0F0H
        .DB 07H
	.DB 0F0H
        .DB 07H

.org 3810H	
	.DB 0F0H
        .DB 07H
        .DB 08H
        .DB 08H
        .DB 00H
        .DB 08H
        .DB 10H
        .DB 08H
        .DB 10H
        .DB 08H
        .DB 10H
        .DB 08H
        .DB 0F8H
        .DB 07H
        .DB 1FH
        .DB 08H

.org 3820H	
	.DB 60H
        .DB 0AH
        .DB 60H
	.DB 0AH
        .DB 60H
        .DB 0AH
        .DB 60H
        .DB 0AH
        .DB 60H
	.DB 0AH
        .DB 60H
	.DB 0AH
        .DB 60H
	.DB 0AH
        .DB 60H
	.DB 0AH

.org 3830H	
	.DB 60H
	.DB 0AH
        ADD B
        LDAX B
        ANA B
        LDAX B
        ORA B
        LDAX B
        RNZ
        LDAX B
        ORA H
        LDAX B
        XRA B
        LDAX B
        RNC
        LDAX B
        .DB 08H ;UNRECOGNIZED
        INR C
        .DB 08H ;UNRECOGNIZED
        INR C
        .DB 08H ;UNRECOGNIZED
        INR C
        .DB 08H ;UNRECOGNIZED
        INR C
        .DB 08H ;UNRECOGNIZED
        INR C
        .DB 08H ;UNRECOGNIZED
        INR C
        .DB 08H ;UNRECOGNIZED
        INR C
        .DB 08H ;UNRECOGNIZED
        INR C
        .DB 08H ;UNRECOGNIZED
        INR C
        .DB 08H ;UNRECOGNIZED
        INR C
        MOV B,B
        INR C
        MOV D,B
        INR C
        MOV H,B
        INR C
        ORA B
        INR C
        INR L
        DCR C
        MOV C,B
        DCR C
        ADD B
        DCR C
        ADD B
        DCR C
        ADD B
        DCR C
        ADD B
        DCR C
        ADD B
        DCR C
        ADD B
        DCR C
        ADD B
        DCR C
        ADD B
        DCR C
        ADD B
        DCR C
        ADD B
        DCR C
        CM L0615
        MVI C,80H
        MVI C,0F0H
        MVI C,88H
        RRC
        RM
        MVI C,0AH
        RRC
        LDAX B
        RRC
        LDAX B
        RRC
        LDAX B
        RRC
        LDAX B
        RRC
        LDAX B
        RRC
        LDAX B
        RRC
        LDAX B
        RRC
        LDAX B
        RRC
        LDAX B
        RRC
        RNZ
        .DB 10H ;UNRECOGNIZED
        RPO
        .DB 10H ;UNRECOGNIZED
        RNZ
        .DB 10H ;UNRECOGNIZED
        MOV C,B
        STAX D
        ORA B
        LXI D,10F0H
        SUB B
        .DB 10H ;UNRECOGNIZED
        SUB B
        .DB 10H ;UNRECOGNIZED
        SUB B
        .DB 10H ;UNRECOGNIZED
        SUB B
        .DB 10H ;UNRECOGNIZED
        SUB B
        .DB 10H ;UNRECOGNIZED
        SUB B
        .DB 10H ;UNRECOGNIZED
        SUB B
        .DB 10H ;UNRECOGNIZED
        SUB B
        .DB 10H ;UNRECOGNIZED
        SUB B
        .DB 10H ;UNRECOGNIZED
        SUB B
        .DB 10H ;UNRECOGNIZED
        RIM
        DCR D
        MOV B,B
        DCR D
        MOV M,B
        DCR D
        SIM
        DCR D
        MOV B,B
        INR D
        INR L
        INX D
        INR C
        STAX D
        INR C
        STAX D
        INR C
        STAX D
        INR C
        STAX D
        INR C
        STAX D
        INR C
        STAX D
        INR C
        STAX D
        INR C
        STAX D
        INR C
        STAX D
        INR C
        STAX D
        .DB 28H ;UNRECOGNIZED
        DAD D
        .DB 28H ;UNRECOGNIZED
        DAD D
        XRA B
        DAD D
        RPE
        DAD D
        SUB B
        .DB 18H ;UNRECOGNIZED
        XRA B
        MVI D,88H
        INX D
        ADC B
        INX D
        ADC B
        INX D
        ADC B
        INX D
        ADC B
        INX D
        ADC B
        INX D
        ADC B
        INX D
        ADC B
        INX D
        ADC B
        INX D
        ADC B
        INX D
        ADD B
        INR E
        ADD B
        INR E
        NOP
        DCR E
        RNC
        INR E
        CMP B
        DCX D
        DCR H
        DAD D
        INR B
        DCR D
        INR B
        DCR D
        INR B
        DCR D
        INR B
        DCR D
        INR B
        DCR D
        INR B
        DCR D
        INR B
        DCR D
        INR B
        DCR D
        INR B
        DCR D
        INR B
        DCR D
        MOV H,C
        RAR
        ADC D
        RAR
        ANA H
        MVI E,83H
        MVI E,30H
        MVI E,0C0H
        DCX D
        ADC D
        MVI D,8AH
        MVI D,8AH
        MVI D,8AH
        MVI D,8AH
        MVI D,8AH
        MVI D,8AH
        MVI D,8AH
        MVI D,8AH
        MVI D,8AH
        MVI D,0B4H
        LXI H,21F8H
	.DB 0E4H
	.DB 20H
	.DB 0C9H
        RIM
        HLT
        RIM
        .DB 28H ;UNRECOGNIZED
        DCR E
        MVI B,18H
        MVI B,18H
        MVI B,18H
        MVI B,18H
        MVI B,18H
        MVI B,18H
        MVI B,18H
        MVI B,18H
        MVI B,18H
        MVI B,18H
        INX H
        INR H
        MOV A,B
        INR H
        INR H
        INX H
        NOP
        INX H
        XRA L
        SHLD 1F0DH
        ADC H
        DAD D
        ADC H
        DAD D
        ADC H
        DAD D
        ADC H
        DAD D
        ADC H
        DAD D
        ADC H
        DAD D
        ADC H
        DAD D
        ADC H
        DAD D
        ADC H
        DAD D
        ADC H
        DAD D
        DAD SP
        DAA
	.DB 0F4H
	.DB 26H
	.DB 70H
        DCR H
        MOV B,M
        DCR H
        RRC
        DCR H
        NOP
        LXI H,1DB0H
        ORA B
        DCR E
        ORA B
        DCR E
        ORA B
        DCR E
        ORA B
        DCR E
        ORA B
        DCR E
        ORA B
        DCR E
        ORA B
        DCR E
        ORA B
        DCR E
        ORA B
        DCR E
        MVI E,29H
        MVI E,29H
        MVI E,29H
        MVI E,29H
        MVI E,29H
        MVI E,29H
        .DB 18H ;UNRECOGNIZED
        NOP
        .DB 18H ;UNRECOGNIZED
        NOP
        .DB 18H ;UNRECOGNIZED
        NOP
        .DB 18H ;UNRECOGNIZED
        NOP
        .DB 18H ;UNRECOGNIZED
        NOP
        .DB 18H ;UNRECOGNIZED
        NOP
        .DB 18H ;UNRECOGNIZED
        NOP
        .DB 18H ;UNRECOGNIZED
        NOP
        .DB 18H ;UNRECOGNIZED
        NOP
        .DB 18H ;UNRECOGNIZED
        NOP
        .DB 18H ;UNRECOGNIZED
        NOP
        .DB 18H ;UNRECOGNIZED
        NOP
        .DB 18H ;UNRECOGNIZED
        NOP
        .DB 18H ;UNRECOGNIZED
        NOP
        .DB 18H ;UNRECOGNIZED
        NOP
        .DB 18H ;UNRECOGNIZED
        NOP
        .DB 18H ;UNRECOGNIZED
        NOP
        .DB 18H ;UNRECOGNIZED
        NOP
        .DB 18H ;UNRECOGNIZED
        NOP
        LXI H,3900H
        NOP
        MOV C,D
        NOP
        MOV E,D
        NOP
        MOV H,A
        NOP
        MOV L,E
        NOP
        MOV H,A
        NOP
        MOV H,E
        NOP
        MOV E,D
        NOP
        MOV D,D
        NOP
        DAD SP
        NOP
        DAD SP
        NOP
        DAD SP
        NOP
        MOV D,B
        NOP
        MOV E,B
        NOP
        MOV H,D
        NOP
        MOV M,H
        NOP
        ANA C
        NOP
        XRA D
        NOP
        RNZ
        NOP
        RNC
        NOP
	.DB 0E4H
	.DB 00H
	.DB 0D6H
        NOP
	.DB 0DCH
	.DB 00H
	.DB 0DCH
        NOP
	.DB 0D2H
	.DB 00H
	.DB 0D2H
        NOP
        CMP M
        NOP
        SUB C
        NOP
        CMP H
        NOP
        RPO
        NOP
        RM
        NOP
        STAX B
        LXI B,0105H
        .DB 18H ;UNRECOGNIZED
        LXI B,0131H
        INR A
        LXI B,0142H
        MOV B,H
        LXI B,013CH
        STC
        LXI B,0137H
        STC
        LXI B,0113H
        XCHG
        NOP
        .DB 38H ;UNRECOGNIZED
        LXI B,0162H
        MOV A,B
        LXI B,018AH
        MOV H,M
        LXI B,0182H
        SUB H
        LXI B,01A0H
        ANA E
        LXI B,01A8H
        SUB B
        LXI B,0198H
        ADC M
        LXI B,0180H
        MOV L,B
        LXI B,0143H
        ANA H
        LXI B,01DFH
        RM
        LXI B,01FAH
        RNC
        LXI B,01E4H
	.DB 0FCH
	.DB 01H
	.DB 06H
        STAX B
        .DB 08H ;UNRECOGNIZED
        STAX B
        .DB 08H ;UNRECOGNIZED
        STAX B
        RM
        LXI B,01F8H
	.DB 0F2H
	.DB 01H
	.DB 0E0H
        LXI B,01C8H
        SBB H
        LXI B,0250H
        HLT
        STAX B
        ADD H
        STAX B
        SUB B
        STAX B
        MOV B,B
        STAX B
        MOV D,D
        STAX B
        MOV L,H
        STAX B
        MOV A,H
        STAX B
        MOV A,D
        STAX B
        MOV A,M
        STAX B
        MOV L,B
        STAX B
        MOV H,B
        STAX B
        MOV L,D
        STAX B
        MOV D,H
        STAX B
        LHLD 0F602H
        LXI B,02C8H
        RP
        STAX B
        RRC
        INX B
        .DB 18H ;UNRECOGNIZED
        INX B
        ORA H
        STAX B
        RNC
        STAX B
	.DB 0EAH
	.DB 02H
	.DB 0FAH
        STAX B
        INX B
        INX B
        .DB 08H ;UNRECOGNIZED
        INX B
        RM
        STAX B
        RPE
        STAX B
        RPE
        STAX B
        RC
        STAX B
        SBB B
        STAX B
        MOV E,B
        STAX B
        MOV B,H
        INX B
        MOV H,D
        INX B
        ADD D
        INX B
        SUB B
        INX B
        INR L
        INX B
        MOV B,D
        INX B
        MOV E,M
        INX B
        MOV M,C
        INX B
        MOV A,B
        INX B
        MOV A,E
        INX B
        MOV L,B
        INX B
        MOV L,B
        INX B
        MOV E,H
        INX B
        MOV C,D
        INX B
        NOP
        INX B
        RNZ
        STAX B
        SBB C
        INX B
        SBI 03H
	.DB 0E4H
	.DB 03H
	.DB 0F4H
        INX B
        SUB D
        INX B
        ANA M
        INX B
	.DB 0C4H
	.DB 03H
	.DB 0D0H
        INX B
	.DB 0DCH
	.DB 03H
	.DB 0E4H
        INX B
        RC
        INX B
        RNC
        INX B
	.DB 0C4H
	.DB 03H
	.DB 0C0H
        INX B
        MOV H,H
        INX B
        INR H
        INX B
	.DB 0D2H
	.DB 03H
	.DB 024H
        INR B
        DCR H
        INR B
        .DB 38H ;UNRECOGNIZED
        INR B
        RST 6
        INX B
        LDAX B
        INR B
        .DB 28H ;UNRECOGNIZED
        INR B
        INR M
        INR B
        INR A
        INR B
        MOV C,M
        INR B
        INR A
        INR B
        MOV B,B
        INR B
        SIM
        INR B
        SIM
        INR B
        ACI 03H
        ADD M
        INX B
        MVI A,04H
        MOV M,H
        INR B
        SUB B
        INR B
        SBB D
        INR B
        MOV D,B
        INR B
        MOV H,C
        INR B
        ADC D
        INR B
        ANA B
        INR B
        XRA H
        INR B
        ORA A
        INR B
        CMP B
        INR B
        ANA B
        INR B
        ANA B
        INR B
        SUB A
        INR B
        MOV B,B
        INR B
        RPO
        INX B
        ORA M
        INR B
        PUSH PSW
        INR B
        SPHL
        INR B
        RLC
        DCR B
        CMP B
        INR B
	.DB 0D2H
	.DB 04H
	.DB 0F8H
        INR B
        LDAX B
        DCR B
        MVI D,05H
        .DB 28H ;UNRECOGNIZED
        DCR B
        RIM
        DCR B
        INR D
        DCR B
        .DB 10H ;UNRECOGNIZED
        DCR B
        NOP
        DCR B
        ANA H
        INR B
        MOV C,B
        INR B
        RIM
        MVI B,20H
        MVI B,20H
        MVI B,30H
        MVI B,0A0H
        DCR B
        ANA B
        DCR B
        ORA B
        DCR B
        RNZ
        DCR B
        RNC
        DCR B
        RZ
        DCR B
        RPO
        DCR B
        RNC
        DCR B
        RP
        DCR B
        RNC
        DCR B
        SUB B
        DCR B
        MOV H,B
        MVI B,38H
        .DB 08H ;UNRECOGNIZED
        .DB 38H ;UNRECOGNIZED
        .DB 08H ;UNRECOGNIZED
        .DB 38H ;UNRECOGNIZED
        .DB 08H ;UNRECOGNIZED
        .DB 38H ;UNRECOGNIZED
        .DB 08H ;UNRECOGNIZED
        .DB 38H ;UNRECOGNIZED
        .DB 08H ;UNRECOGNIZED
        MOV D,B
        .DB 08H ;UNRECOGNIZED
        MOV D,B
        .DB 08H ;UNRECOGNIZED
        RIM
        .DB 08H ;UNRECOGNIZED
        RP
        RLC
        .DB 08H ;UNRECOGNIZED
        .DB 08H ;UNRECOGNIZED
        NOP
        .DB 08H ;UNRECOGNIZED
        .DB 10H ;UNRECOGNIZED
        .DB 08H ;UNRECOGNIZED
        .DB 10H ;UNRECOGNIZED
        .DB 08H ;UNRECOGNIZED
        .DB 10H ;UNRECOGNIZED
        .DB 08H ;UNRECOGNIZED
        RNZ
        RLC
        MOV A,B
        RLC
        MOV H,B
        DAD B
        MOV H,B
        DAD B
        MOV H,B
        DAD B
        MOV H,B
        DAD B
        MOV H,B
        DAD B
        MOV H,B
        DAD B
        MOV H,B
        DAD B
        MOV L,B
        DAD B
        NOP
        DAD B
        .DB 10H ;UNRECOGNIZED
        DAD B
        INR H
        DAD B
        SIM
        DAD B
        MOV B,B
        DAD B
        SIM
        DAD B
        RPO
        .DB 08H ;UNRECOGNIZED
        ANA B
        .DB 08H ;UNRECOGNIZED
        .DB 10H ;UNRECOGNIZED
        DCX B
        .DB 10H ;UNRECOGNIZED
        DCX B
        .DB 10H ;UNRECOGNIZED
        DCX B
        .DB 10H ;UNRECOGNIZED
        DCX B
        .DB 10H ;UNRECOGNIZED
        DCX B
        .DB 10H ;UNRECOGNIZED
        DCX B
        .DB 10H ;UNRECOGNIZED
        DCX B
        .DB 10H ;UNRECOGNIZED
        DCX B
        .DB 10H ;UNRECOGNIZED
        DCX B
        .DB 38H ;UNRECOGNIZED
        DCX B
        MOV H,B
        DCX B
        MOV M,B
        DCX B
        MOV H,B
        DCX B
        MOV L,B
        DCX B
        RP
        LDAX B
        ANA B
        LDAX B
        NOP
        NOP
        NOP
        NOP
        NOP
        NOP
        NOP
        NOP
        NOP
        NOP
        NOP
        NOP
        NOP
        NOP
        NOP
        NOP
        NOP
        NOP
        NOP
        NOP
        NOP
        NOP
        NOP
        NOP
        NOP
        NOP
        NOP
        NOP
        NOP
        NOP
        NOP
        NOP
        NOP
        NOP
        NOP
        NOP
        NOP
        NOP
        NOP
        NOP
        NOP
        NOP
        NOP
        NOP
        NOP
        NOP
        NOP
        NOP
        NOP
        NOP
        NOP
        NOP
        NOP
        NOP
        NOP
        NOP
        NOP
        NOP
        NOP
        NOP
        NOP
        NOP
        NOP
        NOP
        NOP
        NOP
        NOP
        NOP
        NOP
        NOP
        NOP
        NOP
        NOP
        NOP
        NOP
        NOP
        NOP
        NOP
        NOP
        NOP
        NOP
        NOP
        NOP
        NOP
        NOP
        NOP
        NOP
        NOP
        NOP
        NOP
        NOP
        NOP
        NOP
        NOP
        NOP
        NOP
        MOV H,B
        MVI B,60H
        MVI B,60H
        MVI B,60H
        MVI B,60H
        MVI B,60H
        MVI B,60H
        MVI B,60H
        MVI B,60H
        MVI B,80H
        MVI B,60H
        MVI B,70H
        MVI B,70H
        MVI B,70H
        MVI B,20H
        MVI B,10H
        MVI B,0F0H
        RLC
        RP
        RLC
        RP
        RLC
        RP
        RLC
        RP
        RLC
        RP
        RLC
        RP
        RLC
        RP
        RLC
        RP
        RLC
        .DB 08H ;UNRECOGNIZED
        .DB 08H ;UNRECOGNIZED
        NOP
        .DB 08H ;UNRECOGNIZED
        .DB 10H ;UNRECOGNIZED
        .DB 08H ;UNRECOGNIZED
        .DB 10H ;UNRECOGNIZED
        .DB 08H ;UNRECOGNIZED
        .DB 10H ;UNRECOGNIZED
        .DB 08H ;UNRECOGNIZED
	.DB 0DCH
	.DB 07H
	.DB 89H
        RLC
        MOV H,B
        LDAX B
        MOV H,B
        LDAX B
        MOV H,B
        LDAX B
        MOV H,B
        LDAX B
        MOV H,B
        LDAX B
        MOV H,B
        LDAX B
        MOV H,B
        LDAX B
        MOV H,B
        LDAX B
        MOV H,B
        LDAX B
        ADD B
        LDAX B
        ANA B
        LDAX B
        ORA B
        LDAX B
        RNZ
        LDAX B
        ORA H
        LDAX B
        MOV E,D
        LDAX B
        RM
        DAD B
        .DB 08H ;UNRECOGNIZED
        INR C
        .DB 08H ;UNRECOGNIZED
        INR C
        .DB 08H ;UNRECOGNIZED
        INR C
        .DB 08H ;UNRECOGNIZED
        INR C
        .DB 08H ;UNRECOGNIZED
        INR C
        .DB 08H ;UNRECOGNIZED
        INR C
        .DB 08H ;UNRECOGNIZED
        INR C
        .DB 08H ;UNRECOGNIZED
        INR C
        .DB 08H ;UNRECOGNIZED
        INR C
        .DB 08H ;UNRECOGNIZED
        INR C
        MOV B,B
        INR C
        MOV D,B
        INR C
        MOV H,B
        INR C
        MOV D,B
        INR C
        .DB 08H ;UNRECOGNIZED
        INR C
        MOV M,B
        DCX B
        ADD B
        DCR C
        ADD B
        DCR C
        ADD B
        DCR C
        ADD B
        DCR C
        ADD B
        DCR C
        ADD B
        DCR C
        ADD B
        DCR C
        ADD B
        DCR C
        ADD B
        DCR C
        ADD B
        DCR C
        CM L0615
        MVI C,00H
        MVI C,0F0H
        DCR C
        SBB B
        DCR C
        CMP H
        INR C
        LDAX B
        RRC
        LDAX B
        RRC
        LDAX B
        RRC
        LDAX B
        RRC
        LDAX B
        RRC
        LDAX B
        RRC
        LDAX B
        RRC
        LDAX B
        RRC
        LDAX B
        RRC
        LDAX B
        RRC
        ORA B
        RRC
        RNZ
        RRC
        ANA B
        RRC
        SUB B
        RRC
        .DB 38H ;UNRECOGNIZED
        RRC
        DCR E
        MVI C,90H
        .DB 10H ;UNRECOGNIZED
        SUB B
        .DB 10H ;UNRECOGNIZED
        SUB B
        .DB 10H ;UNRECOGNIZED
        SUB B
        .DB 10H ;UNRECOGNIZED
        SUB B
        .DB 10H ;UNRECOGNIZED
        SUB B
        .DB 10H ;UNRECOGNIZED
        SUB B
        .DB 10H ;UNRECOGNIZED
        SUB B
        .DB 10H ;UNRECOGNIZED
        SUB B
        .DB 10H ;UNRECOGNIZED
        SUB B
        .DB 10H ;UNRECOGNIZED
        ADD B
        LXI D,11A0H
        LDA 3011H
        LXI D,10F0H
        MOV M,H
        RRC
        INR C
        STAX D
        INR C
        STAX D
        INR C
        STAX D
        INR C
        STAX D
        INR C
        STAX D
        INR C
        STAX D
        INR C
        STAX D
        INR C
        STAX D
        INR C
        STAX D
        INR C
        STAX D
        INR H
        INX D
        MOV D,B
        INX D
        RPO
        STAX D
	.DB 0CAH
	.DB 12H
	.DB 80H
        STAX D
        RPO
        .DB 10H ;UNRECOGNIZED
        ADC B
        INX D
        ADC B
        INX D
        ADC B
        INX D
        ADC B
        INX D
        ADC B
        INX D
        ADC B
        INX D
        ADC B
        INX D
        ADC B
        INX D
        ADC B
        INX D
        ADC B
        INX D
        ANI 14H
        .DB 18H ;UNRECOGNIZED
        DCR D
        ADD B
        INR D
        MOV L,M
        INR D
        .DB 28H ;UNRECOGNIZED
        INR D
        MOV C,B
        STAX D
        INR B
        DCR D
        INR B
        DCR D
        INR B
        DCR D
        INR B
        DCR D
        INR B
        DCR D
        INR B
        DCR D
        INR B
        DCR D
        INR B
        DCR D
        INR B
        DCR D
        INR B
        DCR D
        XRA B
        MVI D,0C6H
        MVI D,20H
        MVI D,08H
        MVI D,0CCH
        DCR D
        LDAX B
        INR D
        ADC D
        MVI D,8AH
        MVI D,8AH
        MVI D,8AH
        MVI D,8AH
        MVI D,8AH
        MVI D,8AH
        MVI D,8AH
        MVI D,8AH
        MVI D,8AH
        MVI D,56H
        .DB 18H ;UNRECOGNIZED
        ADC B
        .DB 18H ;UNRECOGNIZED
        RNZ
        RAL
        XRA H
        RAL
        MOV M,B
        RAL
        MVI C,15H
        MVI B,18H
        MVI B,18H
        MVI B,18H
        MVI B,18H
        MVI B,18H
        MVI B,18H
        MVI B,18H
        MVI B,18H
        MVI B,18H
        MVI B,18H
        .DB 18H ;UNRECOGNIZED
        LDAX D
        MOV D,H
        LDAX D
        MOV H,B
        DAD D
        MOV B,M
        DAD D
        LDAX B
        DAD D
        MOV L,H
        MVI D,8CH
        DAD D
        ADC H
        DAD D
        ADC H
        DAD D
        ADC H
        DAD D
        ADC H
        DAD D
        ADC H
        DAD D
        ADC H
        DAD D
        ADC H
        DAD D
        ADC H
        DAD D
        ADC H
        DAD D
        MOV D,D
        INR E
        RIM
        INR E
        .DB 08H ;UNRECOGNIZED
        DCX D
	.DB 0EAH
	.DB 1AH
	.DB 0C2H
        LDAX D
	.DB 0D4H
	.DB 17H
	.DB 0B0H
        DCR E
        ORA B
        DCR E
        ORA B
        DCR E
        ORA B
        DCR E
        ORA B
        DCR E
        ORA B
        DCR E
        ORA B
        DCR E
        ORA B
        DCR E
        ORA B
        DCR E
        ORA B
        DCR E
        ORA B
        DCR E
        ORA B
        DCR E
        ORA B
        DCR E
        ORA B
        DCR E
        ORA B
        DCR E
        ORA B
        DCR E
        MOV H,C
        NOP
        MOV E,D
        NOP
        MOV D,A
        NOP
        MOV D,B
        NOP
        MOV C,E
        NOP
        MOV C,C
        NOP
        MOV B,M
        NOP
        MOV B,E
        NOP
        CMC
        NOP
        STC
        NOP
        DCR M
        NOP
        INX SP
        NOP
        DCR L
        NOP
        INR L
        NOP
        INR L
        NOP
        INR L
        NOP
        SUB D
        NOP
        ADC B
        NOP
        ADD L
        NOP
        MOV A,E
        NOP
        MOV M,H
        NOP
        MOV M,B
        NOP
        MOV L,H
        NOP
        MOV L,B
        NOP
        MOV H,E
        NOP
        MOV E,B
        NOP
        MOV D,H
        NOP
        MOV D,C
        NOP
        MOV C,E
        NOP
        MOV C,C
        NOP
        MOV C,C
        NOP
        MOV C,C
        NOP
	.DB 0C4H
	.DB 00H
	.DB 0BAH
        NOP
        ORA H
        NOP
        XRA D
        NOP
        ANA C
        NOP
        SBB H
        NOP
        SUB M
        NOP
        SUB C
        NOP
        ADC D
        NOP
        MOV A,L
        NOP
        MOV A,B
        NOP
        MOV M,L
        NOP
        MOV L,L
        NOP
        MOV L,H
        NOP
        MOV L,H
        NOP
        MOV L,H
        NOP
        RM
        NOP
        .DB 0EDH ;UNRECOGNIZED
        NOP
        RST 4
        NOP
	.DB 0DCH
	.DB 00H
	.DB 0D1H
        NOP
	.DB 0CAH
	.DB 00H
	.DB 0C4H
        NOP
        CMP L
        NOP
        ORA H
        NOP
        ANA A
        NOP
        ANA B
        NOP
        SBB H
        NOP
        SUB L
        NOP
        SUB E
        NOP
        SUB E
        NOP
        SUB E
        NOP
        MVI L,01H
        INR H
        LXI B,011CH
        LXI D,0401H
        LXI B,00FCH
	.DB 0F4H
	.DB 00H
	.DB 0ECH
        NOP
	.DB 0E2H
	.DB 00H
	.DB 0D5H
        NOP
	.DB 0CDH
	.DB 00H
	.DB 0C8H
        NOP
	.DB 0C2H
	.DB 00H
	.DB 0C0H
        NOP
        RNZ
        NOP
        RNZ
        NOP
        MOV H,A
        LXI B,015EH
        MOV D,L
        LXI B,014CH
        INR A
        LXI B,0132H
        DAD H
        LXI B,0120H
        STAX D
        LXI B,0107H
        CPI 00H
        SPHL
        NOP
        PUSH PSW
        NOP
	.DB 0F2H
	.DB 00H
	.DB 0F2H
        NOP
	.DB 0F2H
	.DB 00H
	.DB 00CH
        LXI B,0104H
        EI
        NOP
        ORI 00H
        MOV M,A
        LXI B,016AH
        MOV H,C
        LXI B,0158H
        MOV C,C
        LXI B,013EH
        INR M
        LXI B,012DH
        INR L
        LXI B,0129H
        DAD H
        LXI B,0129H
        .DB 18H ;UNRECOGNIZED
        LXI B,0110H
        MVI B,01H
        STAX B
        LXI B,018AH
        MOV A,H
        LXI B,0172H
        MOV L,D
        LXI B,015BH
        MOV D,B
        LXI B,0145H
        MVI A,01H
        MVI A,01H
        DCX SP
        LXI B,013BH
        DCX SP
        LXI B,0128H
        RIM
        LXI B,0119H
        INX D
        LXI B,01A6H
        SBB B
        LXI B,018DH
        ADD D
        LXI B,0175H
        .DB 6EH
        LXI B,0169H
        .DB 64H
        LXI B,0164H
        MOV H,E
        LXI B,0163H
        MOV H,E
        LXI B,0140H
        .DB 38H ;UNRECOGNIZED
        LXI B,0130H
        .DB 28H ;UNRECOGNIZED
        LXI B,01C1H
        ORA H
        LXI B,01B3H
        SBB M
        LXI B,0195H
        SUB E
        LXI B,0192H
        ADC A
        LXI B,0190H
        SUB B
        LXI B,0190H
        SUB B
        LXI B,0209H
        CPI 01H
        DI
        LXI B,01ECH
	.DB 0DAH
	.DB 01H
	.DB 0CFH
        LXI B,01C6H
        CMP L
        LXI B,01B9H
        CMP C
        LXI B,01BDH
        CMP L
        LXI B,01C0H
        RNZ
        LXI B,01C0H
        RNZ
        LXI B,0217H
        INR C
        STAX B
        INR B
        STAX B
        .DB 0FDH ;UNRECOGNIZED
        LXI B,01F0H
        PUSH H
        LXI B,01E2H
        RST 3
        LXI B,01E8H
        .DB 0EDH ;UNRECOGNIZED
        LXI B,01F3H
        DI
        LXI B,01EFH
	.DB 0EAH
	.DB 01H
	.DB 0EAH
        LXI B,01EAH
        DAA
        STAX B
        INR E
        STAX B
        INX D
        STAX B
        INR C
        STAX B
        LXI B,0FA02H
        LXI B,01FEH
        LXI B,1602H
        STAX B
        SHLD 2902H
        STAX B
        DAA
        STAX B
        MVI E,02H
        RAL
        STAX B
        RAL
        STAX B
        RAL
        STAX B
        LXI SP,3102H
        STAX B
        LXI SP,3102H
        STAX B
        LXI SP,3102H
        STAX B
        DAD SP
        STAX B
        MOV B,B
        STAX B
        MOV A,M
        STAX B
        SBB C
        STAX B
        SBB E
        STAX B
        SUB D
        STAX B
        ADD L
        STAX B
        MOV A,M
        STAX B
        MOV A,M
        STAX B
        MOV A,M
        STAX B
        NOP
        LXI B,0100H
        NOP
        LXI B,0100H
        NOP
        LXI B,0100H
        NOP
        LXI B,0200H
        DI
        STAX B
        DI
        STAX B
        DI
        STAX B
        DI
        STAX B
        DI
        STAX B
        DI
        STAX B
        DI
        STAX B
        DI
        STAX B
        NOP
        LXI B,0100H
        NOP
        LXI B,0100H
        NOP
        LXI B,0100H
        NOP
        LXI B,0100H
        DI
        STAX B
        DI
        STAX B
        DI
        STAX B
        DI
        STAX B
        DI
        STAX B
        DI
        STAX B
        DI
        STAX B
        DI
        STAX B
	.DB 00H
	.DB 00H
	.DB 00H
	.DB 00H
	.DB 00H
	.DB 00H
	.DB 00H
	.DB 00H
	.DB 00H
	.DB 00H
	.DB 00H
	.DB 00H
	.DB 00H
	.DB 00H
	.DB 00H
	.DB 00H
	.DB 00H
	.DB 00H
	.DB 00H
	.DB 00H
	.DB 00H
	.DB 00H
	.DB 00H
	.DB 00H
	.DB 00H
	.DB 00H
	.DB 00H
	.DB 00H
  